I tried with the following code but when I run it the function is not shown reversed although the number I chose is even:
const myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const number = 32;
const myReversedArray = number => {
if (number % 2 === 0) {
return myArray.reverse();
} else {
return myArray;
}
}
console.log(myReversedArray());
I expected the function to be shown in reverse since the number I chose is even, but instead it is shown in the normal order (1, 2, 3, 4, 5, 6, 7, 8, 9, 10).