python-vs-javascript icon indicating copy to clipboard operation
python-vs-javascript copied to clipboard

Improve readability of JS examples

Open EddiG opened this issue 7 years ago • 0 comments

As an example, I take this one

const someDict = { one: 1, two: 2, three: 3 }

// one 1
// two 2
// three 3

Object.entries(someDict).forEach(element => {
  console.log(`${element[0]} ${element[1]}`)
})

I think you may improve it by giving the meaningful names for the variables as you do in Python example

const someDict = { one: 1, two: 2, three: 3 }

// one 1
// two 2
// three 3

Object.entries(someDict).forEach(([key, value]) => {
  console.log(`${key} ${value}`)
})

There are other examples that might be improved in the same way.

EddiG avatar Sep 17 '18 11:09 EddiG