0

code not giving result

why doesn't the following code gives result:- const printOdds = (arr) =>{ arr.forEach(el=> { if (el % 2 != 0) console.log(el); }); }

28th Jul 2020, 6:03 PM
Kumar Sarthak
Kumar Sarthak - avatar
2 Respostas
0
Hello, try const printOdds = (arr) =>{ arr.forEach(el=> { !(el % 2) && console.log(el); }); } printOdds([1,2,3,4,5,6]);
28th Jul 2020, 6:11 PM
bubbleCode
bubbleCode - avatar
0
Code works (output to console) as I tested it.
28th Jul 2020, 6:14 PM
Ipang