I got question today, that I couldn't answer. I would appreciate if you could just explain it to me. Why my array doesn't output [1, 2, 3, 4, 5] but only [2, 3, 4, 5]? This is the code:
let numbers = [1, 2, 3, 4, 5]
let order = numbers.sort((a, b) => {
console.log(a);
});
But when I use this code, it works perfectly fine
let numbers = [1, 2, 3, 4, 5]
let order = numbers.sort((a, b) => {
return a;
})
console.log(order);