I'm trying to solve a simple algorithm where you evaluate that every number in an array is greater than the next one, so I first taught in the Every() method, but when I do a return is always false, but when I console.log() it display true!
How is this possible?
const arr = [3, 2, 1];
const returnRes = arr.every((value, index, arr) => value > arr[index + 1]);
const consoleLogRes = arr.every((value, index, arr) => console.log(value > arr[index + 1]));
console.log(returnRes);
trueyou see is the innerconsole.log()printingtrueonce, and then theeveryterminates becauseconsole.log()returnsundefined