+ 4
A c JS Challenge question which Ä° don't understand
what is the output function func(x) { return function(y) { return function(z) { return x*y+z } } } document. writein(3,2,3) the correct answer is 9
7 Answers
+ 15
@Ammar - post the quizz as it is, not your interpretation of it.
@Kirk - the actual quizz is just fine and the correct answer is 9 đ
+ 12
sorry, I was on the phone before :D
original quizz is :
function func(x) {
return function(y) {
return function(z) {
return x*y+z;
}
}
}
document.write( func(3)(2)(3) );
so func() takes a param "x" that returns
another function that takes a param "y" and returns
another function that takes a param "z" and returns
x*y + z;
when you call func(3)(2)(3) by the time you reach the last function that returns a value x is 3, y is 2, z is 3, so the total result is 3*2+3 = 9
+ 9
Nice explanation sir
+ 6
i think you're missing semicolons sir as well as braces? if im right? correct me if im wrong sir @kirk schafer
+ 5
edit: it looks like the quiz is okay, see @Nikolay's answer]
old.......
1: function func(x)
2: return function(y)
3: return function(z)
4: return x*y+z
Uncaught SyntaxError: Unexpected token 'return', line 2.
[edit: as written...] I'd report that.
+ 4
@rookie - I just copied the question's text; I haven't seen the quiz itself.
@Nikolay's apparently seen it so I edited my answer.
+ 1
Thanks!
And sorry if my writing of the question wasn't clear* the question has since been corrected.