+ 4

Call function inside function (nested functions)

I want to call shoot() function inside animate() function. How can i do that? function shoot(){ bullets.pop() numberOfBullets -= 1 for(var i = 0; i < numberOfBullets; i++){ bullets[i].shoot() } } https://code.sololearn.com/W3iUJwtX589C/?ref=app

10th Sep 2020, 12:30 PM
Tri Satria [NEW]
Tri Satria [NEW] - avatar
7 Answers
+ 2
Case have closed answered correctly by Heng Jun Xi. For more information visit the link below. https://www.sololearn.com/discuss/2488529/?ref=app
10th Sep 2020, 1:33 PM
Tri Satria [NEW]
Tri Satria [NEW] - avatar
+ 2
I see error message "Scene is not defined". Mirielle[ InAcTiVe ]
10th Sep 2020, 12:47 PM
Gordon
Gordon - avatar
10th Sep 2020, 1:05 PM
Abhay
Abhay - avatar
+ 2
Is that what you wanted? Recommendation: don't use onclick of html, use addEventListener or onclick of js. Don't call functions through html! https://code.sololearn.com/WDMJnlBs4Z7I/?ref=app
10th Sep 2020, 1:06 PM
Namit Jain
Namit Jain - avatar
+ 2
We cant place the shoot() outside animate() as since the bullet animation wont occur. Therefore, i wanna place that inside however shoot isnt defined
10th Sep 2020, 1:24 PM
Tri Satria [NEW]
Tri Satria [NEW] - avatar
+ 1
Pass function to animate function and call shoot inside animate ,or what are you trying to do?
10th Sep 2020, 12:35 PM
Abhay
Abhay - avatar
+ 1
If shoot button is clicked, it will call shoot() inside animate() but it wont work that way, so i wanna know how to do given question check my recent question
10th Sep 2020, 12:38 PM
Tri Satria [NEW]
Tri Satria [NEW] - avatar