Please help in explaining this JavaScript code.I am able to understand this code and how it is executed and returning 10 from it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Please help in explaining this JavaScript code.I am able to understand this code and how it is executed and returning 10 from it

Please explain in detail that how it is returning 10 and what is the backend process of it and how it is executed. Please help me. https://code.sololearn.com/W2aJotXh4xCE/?ref=app

13th Jul 2019, 3:55 PM
Ashish
Ashish - avatar
2 Answers
+ 2
The calc function basically executes the third function with the other two parameters, so calc(-1, 9, sub) will be the same as su (-1, 9). The sub function returns y - x, which is 9 - (-1), which is the same as 9 + 1. 9 + 1 is 10
13th Jul 2019, 4:24 PM
Airree
Airree - avatar
- 2
The third Function calc is just taking 2 args and 1 func to call that func again with the same arg being reversed,you gave -1 and 9 and the func calc revoked sub and made it 9 - (- 1) and so it returned 10. Hope that helps ;)
13th Jul 2019, 7:14 PM
raza naqvi
raza naqvi - avatar