I am using a function that takes an array and returns true if all its values are even and false otherwise.
My Code is below and passed array is [ -2, 2, -2, 2 ]
function checkAllEven(arr) {
return arr.every(x=> { x % 2 === 0 });
}
-------------
Output: False
But when I removed curly braces, it works correctly and return true.
function checkAllEven(arr) {
return arr.every(x=> x % 2 === 0 );
}
-------------
Output: True
Just Want to know why it is happening.