We were going through the Array.prototype.sort()
MDN documentation, where we saw an example:
var array1 = [1, 2,3,4,5,6,7,8,9,10];
array1.sort();
console.log(array1);
So the expected output is
[1, 2, 3 , 4, 5, 6, 7, 8, 9, 10]
But insted of this we got
[1, 10, 2, 3, 4, 5, 6, 7, 8, 9]
Why isn’t it sort as we expected?