var arr = [1,2,3,4,5,6]; var a = []; a = arr.filter(function(i){ if(i%2 == 0){ return i } })
What is the first sensory output?
How to make it output [2,4,6]
var arr = [1,2,3,4,5,6]; var a = []; a = arr.filter(function(i){ return i % 2 == 0 }); console.log(a);
Filter accepts true and false, but does not accept the original value of your array.
is the output....
a = [2,4,6]
Execute the specified function (callback) once for each element in the array, and create a new array. This array element is the original array element that returns true when all callback functions are executed.
Filter accepts true and false, but does not accept the original value of your array.
is the output....
Execute the specified function (callback) once for each element in the array, and create a new array. This array element is the original array element that returns true when all callback functions are executed.