JavaScript Challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

JavaScript Challenge

Can someone please explain this question and answer? I donā€™t remember covering this in the JS tutorial. Thank you. What is the output of this code? let p= [4,3,2]; let q= p.map((v,w) => v*w); console.log (q);

3rd Mar 2022, 2:23 PM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar
4 Answers
+ 3
Thank you, Professor Solomoni Railoa for switching on the šŸ’”. I believe I have my shoes on the correct feet now, thanks to your awesome explanations! šŸ™
5th Mar 2022, 3:50 PM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar
+ 1
Harsh Bajpai šŸ‡®šŸ‡³ Thatā€™s the correct answer, but I still donā€™t understand how/why that is the correct answer. Actually, [0,3,4] as an array.
3rd Mar 2022, 3:17 PM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar
+ 1
I went back and reviewed ES6 Map. Evidently, thatā€™s not the same as what this question requires.
3rd Mar 2022, 4:56 PM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar
+ 1
it returns an array like this--> [0, 3, 4] because you are multiplying values with an index of the array Thank You
24th Dec 2022, 4:11 PM
Ghulam mustafa
Ghulam mustafa - avatar