JSFiddle - React, Tailwind, and code Playground

by Siva Subramaniam

JavaScript

var integerArray = [1,2,3,4,5,6];
// Note that an Arrow function is passed into filter function below
// If the function contains only one line, it can be enclosed in ( and ) instead of {}
// The below line of code is equivalent to:
// var evenArray = integerArray.filter((arrayItem) => {return arrayItem % 2 === 0});
// It is also equivalent to:
// var evenArray = integerArray.filter(function (arrayItem) {
//	return arrayItem % 2 === 0;
//});
var evenArray = integerArray.filter((arrayItem) => (arrayItem % 2 === 0));
console.log(evenArray);