ERROR - "Object to Array"
// Noobs:
let number = { one: 1, two: 2, }; let keys = []; for (let numbers in number) { if (number.hasOwnProperty(numbers)) { keys.push(numbers); } } console.log(keys) // [ 'one', 'two' ]
// Pro:
let number = { one: 1, two: 2, }; let key = Object.keys(number) // [ 'one', 'two' ] let value = Object.values(number) // [ 1, 2 ] let entry = Object.entries(number) // [ [ 'one', 1 ], [ 'two', 2 ] ]
Everyone has their own perspective sir.
No he meant your had typos in your variable names. You declared a "number" variable but referenced "numbers" (with an s) in your code examples. The code literally doesn't run.
Agreed.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
ERROR - "Object to Array"
// Noobs:
// Pro:
Everyone has their own perspective sir.
No he meant your had typos in your variable names. You declared a "number" variable but referenced "numbers" (with an s) in your code examples. The code literally doesn't run.
Agreed.