+ 1

How can I understand it?

Please help me to understand it. function func(x) { return(x+1)+x*3; } var y = func(2); var z = func(y); document.write(z); And=37

19th Dec 2016, 3:59 PM
Nirob
Nirob - avatar
3 Answers
+ 3
ok first func(2) return(2+1)+2*3; => 3+6 => func(2)=9 => y=9 second func(y) mean func(9) return(9+1)+9*3; => 10+27 =>37 z = 37 hope you get it ;)
19th Dec 2016, 4:19 PM
Adnen Rebai
Adnen Rebai - avatar
+ 2
This code performs the following operation func(2) = (2+1)+2*3=9 func(y) = func(9)= (9+1)+9*3=37 z=func(y)=37
19th Dec 2016, 4:07 PM
Ravi Kumar
Ravi Kumar - avatar
+ 2
thanks
20th Dec 2016, 1:11 AM
Nirob
Nirob - avatar