Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,678 members, 7,955,500 topics. Date: Sunday, 22 September 2024 at 07:42 AM |
Nairaland Forum / Science/Technology / Programming / Javascript Help (637 Views)
Great Videos To Learn Css, Php, Msql And Javascript [HELP] / Lets Start A Real Web-deveopment Course Here Html+css+javascript+php+mysql / Were Can I Download Free Video Tutorials On Javascript Or Ruby (2) (3) (4)
Javascript Help by cammyjr(m): 10:01am On Jul 04, 2015 |
Good morning , please I need help on this particular page on codecademy's tutorial, I seem to be stuck and its taking forever to find out what's wrong with this code. Its for a dragon slayer game. Kindly assist. var slaying = true; youHit = Math.floor(Math.random() * 2) damageThisRound = Math.floor(Math.random() * 5 + 1) totalDamage = 0 while (slaying) { if (youHit) { console.log("You Hit the Dragon\ !!!" totalDamage += damageThisRound; if (totalDamage >= 4) { console.log("You slew the\ dragon" slaying = false; } else { youHit = Math.floor(Math.random() * 2); } else { console.log("You Lose" slaying = false; } } |
Re: Javascript Help by olaboy33(m): 10:04am On Jul 04, 2015 |
Fgdhjsklatyuioewpbnc,x.z 1 Like |
Re: Javascript Help by cammyjr(m): 10:21am On Jul 04, 2015 |
?? |
Re: Javascript Help by Nobody: 10:47am On Jul 04, 2015 |
Please provide the codecademy page. . . .your code snippet is lacking the condition required in the while loop 1 Like |
Re: Javascript Help by cammyjr(m): 11:17am On Jul 04, 2015 |
Re: Javascript Help by Nobody: 12:07pm On Jul 04, 2015 |
I did not see any error there: The next excercise that gives you a blank screen gives you 4 instructions: all you need to enter is var slaying = true; var youHit = Math.floor(Math.random() * 2); var damageThisRound = Math.floor(Math.random() * 5 + 1); var totalDamage = 0; To move on to the next stage where you learn the while loop. |
Re: Javascript Help by Craigston: 12:12pm On Jul 04, 2015 |
donjayzi:I don't think so. It's testing for a boolean which returns true. OP, any error messages? |
Re: Javascript Help by Nobody: 12:15pm On Jul 04, 2015 |
Craigston:same here var slaying = true; (while slaying) ; infinite loop 1 Like |
Re: Javascript Help by Olumyco(m): 12:30pm On Jul 04, 2015 |
The problem wit d code is traceable to the while loop. |
(1) (Reply)
This Is What The Next Super Mario Should Look Like / I Need "Fastrak" Structural Design Software / Where Can I Learn Programming At A Relatively Cheap Price
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8 |