JavaScript - help with function understanding

Dear reader,

can you please help me understand how does the code below give a result of 15? Thank you!!

function doSomething(a){
function doSomethingElse(a) {
return a-1;
var b;

b = a + doSomethingElse(a*2);


When i try to run your code it doesn’t work
But, if you want to see what happens I would reccoment the following link:

Ahhh sorry!! I forgot to add the last element: doSomething(2)

2 + ((2*2)-1) = 5. This is b
5*3 = 15. This is what you print.

1 Like

got it, thank you so much :sunflower:

I’m glad I could help. Happy coding!