Sorting array javascript not run


#1

Hi! i need to sort array on javascript from the IDE but it doesn’t run :

const array = [3, 2, 1];
array.sort();
console.error(array);

Expected value :

[1, 2, 3]

Actual value :

[3, 2, 1] 

Thanks in advance :slight_smile:


#2

should be
console.log(array) ? – depending on your js engine in use


#3

Your code works. I’ve just tried it.


#4

Try removing “const” from line array declaration

let array = [3,2,1];
array.sort();
console.error(array);