This week's hack is about cleaning duplicate values from Arrays

The Neat Dev version:

let myArr = ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']

console.log([ Set(myArr)])

// Outputs: (7) ["h", "e", "l", "o", "w", "r", "d"]

The Ninja Dev version:

Because, why not add 15 lines of code and useless comments, right!?

let u = [], a = ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']

for(z in a) {
  let t = false

  // Because a for loop is always better than Array.includes()
  for(g in u) {
    // Ninjas reap maximum benefit from IF statements
    if(a[z] === u[g]) // Readability matters
      t = true

  // See? The more IFs, the better


// Outputs: the same, but a little more tired of typing

This post is also available on DEV.