That's because the console.log returns undefined, and it's being used in the call to .map().
console.log
undefined
.map()
var array = [9, 2, 3, 8, 1, 0] var orderedArray = [...array].sort() console.log(array) // [9, 2, 3, 8, 1, 0] console.log(orderedArray) // [0, 1, 2, 3, 8, 9] var logReturn = console.log("hello world") // hello world console.log(logReturn) // undefined
exactly, my point is we should not use map here at all.
map
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.
That's because the
console.log
returnsundefined
, and it's being used in the call to.map()
.exactly, my point is we should not use
map
here at all.