In my code below, I created a fn callback function to return values < 2, after the loop in the map function runs through the array passed as the parameter. But the console is logging an array of booleans instead of values
What am I doing wrong?
var newarr = []
function fn(val){
return val < 3;
}
function map(arr){
for (var i = 0; i < arr.length; i++){
newarr.push(fn(arr[i]));
}
console.log(newarr);
}
map ([1,2,3,4,5,6], fn);
My Result
[ true, true, false, false, false, false ]
val < 3is a condition check and will return Boolean