How do I change this arrow function to normal funcion 🙆 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do I change this arrow function to normal funcion 🙆

const printOdds = (arr) => { arr.forEach (el=>{ if (el % 2 != 0) console.log (el); }); }

23rd Oct 2019, 2:21 PM
Amwata Aseda 🇰🇪
Amwata Aseda 🇰🇪 - avatar
6 Answers
+ 5
Why you wanted to do this? function printOdds(arr) { arr.forEach (function(el) { if (el % 2) console.log (el); }); } a = [10, 23,30,47, 50]; printOdds(a);
23rd Oct 2019, 4:43 PM
Ipang
+ 3
Oh yea thought it a bug at first😃
23rd Oct 2019, 5:58 PM
Amwata Aseda 🇰🇪
Amwata Aseda 🇰🇪 - avatar
+ 2
Thanks Ipang 👍 Been writing codes with an older machine.
23rd Oct 2019, 5:43 PM
Amwata Aseda 🇰🇪
Amwata Aseda 🇰🇪 - avatar
+ 2
Please note forEach won’t work on older version for defined browser. https://caniuse.com/#search=forEach
21st Mar 2020, 12:11 PM
\•/
\•/ - avatar
+ 1
I was told these new standards works if we use updated browser, does it work for you, updated browser?
23rd Oct 2019, 5:47 PM
Ipang
0
eodejdijeijed
15th Mar 2022, 2:34 PM
Mahmoud Elhaj
Mahmoud Elhaj - avatar