JSFiddle - React, Tailwind, and code Playground
JavaScript
const count = function(array) { // Function expression
return array.length;
}
console.log(count([5, 7, 8])); // => 3
const methods = {
numbers: [1, 5, 8],
sum: function() { // Function expression
return this.numbers.reduce(function(acc, num) { // func. expression
return acc + num;
});
}
}
console.log(methods.sum()); // => 14