Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
smriti chawla
2,566 PointsWhy is my code not running?
Hey guys, I was following along the random game video in the JS basics course. Not sure why my code is not running. Can someone please check? https://w.trhou.se/3ne7w2ve7y
I don't see any prompts etc. at all.
2 Answers
Chris Davis
16,280 PointsI found a few syntax errors in your js code. Once i corrected them, it worked.
On lines 8 and 13 you had a space between your parseInt() method calls. Correct syntax is parseInt(someValue)
On line 11, you forgot your closing bracket before your else if
And finally on line 22, you forgot to end your initial if statement with a closing bracket.
This is a perfect example of why working with nested if statements can become hard to maintain. Im sure the next lesson is going to introduce switch statements for complex conditional logic.
Here is a fiddle with the corrected syntax... https://jsfiddle.net/p86yj19a/1/ Hope this helps
Vincentius Ronalto
4,432 PointsThere are some syntax error in your javascript code, I corrected your code, like missing bracket, sorry If there are some mistake in my correction, I am a newbie :D check here: https://w.trhou.se/mx7ybnx08i I also using button for user to click, so if he click the prompt will be fired
Ashish Mehra
3,407 PointsAshish Mehra
3,407 PointsHey smriti chawla , You forget to close if conditions in one or two places which stopping your code from running.