+ 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));
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
+ 4
The answer is 42
+ 2
1,2,3,4,5,6 %2 == 0 means remaining must be =0
2+4+6=12
0
answer is12
0
Function.magic(a,b=20)
{ return a+b; }
Console.log(magic(2));
0
Answer for the above coding
0
Sorry... a,b =40
0
Function.magic(a,b=40)
{ return a+b; }
Console.log(magic(2));
42
0
42
0
the answer will be 42
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
- 1
got it the answer is 12.
- 1
12
- 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