JSFiddle - React, Tailwind, and code Playground

by fairmutex

JavaScript

var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

var r = arr.filter(function (a) {
    if (a > 5) {
        return true;
    } else {
        return false;
    }
});

console.log(r);

var r = arr.map(function(x,i,a){
  return x*x*x;
});
console.log(r);


var r = arr.reduce(function(p,c,i,arry){
return p+c
});
console.log(r)