Can someone please explain this piece of code to me and why b [2] and b [3] are undefined? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can someone please explain this piece of code to me and why b [2] and b [3] are undefined?

var c = [1,2 3,4]; var b = c.filter (function (a) { return (a%2); }); alert (b [0] + b [1]); // outputs 4

23rd Jul 2019, 2:45 PM
Jesse Brite
Jesse Brite - avatar
1 Answer
0
It works fine here. Could you kindly try running it? It's one of the quizzes and I don't understand it Cbr✔[ Not Active ]
23rd Jul 2019, 3:39 PM
Jesse Brite
Jesse Brite - avatar