You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//We will conclude by covering some basic examples using filter().
//To start, let's create an array of random integers. We will have to do this with a for() loop.
var n = Math.floor(Math.random()*10);
var a = [];
for(var i=0;i<n;i++){
a[i] = Math.floor(Math.random()*10);
}
/*
Since filter() requires a callback function to be passed to it as the first argument, we need to write that first. In this case, we'd like to keep the elements of the array which are greater than 5.