Why the result for this forEach
mapping is undefined?
const list = [1, 2, 3, 4, 5, 6, 7];
const result = list.forEach(a => a % 2 === 0 ? a : -a);
console.log(result); // console prints undefined
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…