below is javascript code with filter function. when using below code, it works perfectly-
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
but below code gives an empty array. Why?
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter((word) => {
word.length > 6;
});
console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]