我不知道为什么会这样:
const numbers2 = [45, 5, 9, 16, 25];
const myFunction1 = (numbers2) =>{numbers2.filter(number=>{return number>6})};
console.log("Soy filter con arrowFunction: " + myFunction1(numbers2)); // Soy filter con arrowFunction: undefined
答案 0 :(得分:1)
您缺少回报。参见下面添加的代码。
const numbers2 = [45, 5, 9, 16, 25];
const myFunction1 = (numbers2) =>{
return numbers2.filter(number=>{ // <===== missing return was here
return number>6
}
)
};
console.log("Soy filter con arrowFunction: " + myFunction1(numbers2));