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:osWhy 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