+ 1

need Help

What is the output of the following code? function magic(...nums) { let sum = 0; nums.filter(n => n % 2 == 0).map(el => sum+= el); return sum; } console.log(magic(1, 2, 3, 4, 5, 6));

29th Apr 2019, 9:05 PM
Sundar Maharjan
Sundar Maharjan - avatar
14 Answers
- 4
What is the output of the following code? function magic(...nums) { let sum = 0; nums.filter(n => n % 2 == 0).map(el => sum+= el); return sum; } console.log(magic(1, 2, 3, 4, 5, 6)); Answer is only 12
5th Aug 2019, 2:14 PM
Aftab Ashraf
Aftab Ashraf - avatar
+ 4
The answer is 42
7th May 2020, 10:46 PM
Olga Patapenka
Olga Patapenka - avatar
+ 2
1,2,3,4,5,6 %2 == 0 means remaining must be =0 2+4+6=12
6th May 2020, 10:32 PM
JM Y
JM Y - avatar
0
answer is12
27th Jan 2020, 7:27 AM
sales jayson
sales jayson - avatar
0
Function.magic(a,b=20) { return a+b; } Console.log(magic(2));
3rd May 2020, 9:57 AM
A.Rihana Barvin
0
Answer for the above coding
3rd May 2020, 9:58 AM
A.Rihana Barvin
0
Sorry... a,b =40
3rd May 2020, 9:59 AM
A.Rihana Barvin
0
Function.magic(a,b=40) { return a+b; } Console.log(magic(2)); 42
7th May 2020, 10:47 PM
Olga Patapenka
Olga Patapenka - avatar
0
42
17th May 2020, 7:51 AM
kamal eldein Mohammed Ahmed Warrag
0
the answer will be 42
23rd May 2020, 7:29 PM
Pramod Vishwakarma
Pramod Vishwakarma - avatar
0
What is the output of the following code? function magic(...nums) { let sum = 0; nums.filter(n => n % 2 == 0).map(el => sum+= el); return sum; } console.log(magic(1, 2, 3, 4, 5, 6)); Answer is only 12
27th Jun 2022, 6:31 AM
Bexzod
Bexzod - avatar
- 1
got it the answer is 12.
29th Apr 2019, 9:07 PM
Sundar Maharjan
Sundar Maharjan - avatar
- 1
12
16th Sep 2019, 11:09 AM
ISINGIZWE GASANA Aline
ISINGIZWE GASANA Aline - avatar
- 1
What is the output of the following code? function magic(...nums) { let sum = 0; nums.filter(n => n % 2 == 0).map(el => sum+= el); return sum; } console.log(magic(1, 2, 3, 4, 5, 6)); Answer is only 12
10th Feb 2020, 8:20 AM
Pranjal Singh
Pranjal Singh - avatar