Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,103 members, 7,953,356 topics. Date: Thursday, 19 September 2024 at 02:56 PM |
Nairaland Forum / Science/Technology / Webmasters / Andela Lab Solution(fizzbuzz) (750 Views)
Google/andela Learning Community (ALC) 2.0 For Nigerians & Kenyans / What Is The Cut-off For Andela Homestudy Test? / Andela Lab Solution(fizzbuzz) (2) (3) (4)
(1) (Reply)
Andela Lab Solution(fizzbuzz) by Enygma: 10:05am On Jun 25, 2016 |
Hello everyone, I need you guys to look into this code for me. I have completed 93% of the Homestudy,I need your urgent help! JAVASCRIPT LAB QUESTION Create a function fizzBuzz to return 'Fizz', 'Buzz', 'FizzBuzz', or the argument it receives, all depending on the argument of the function, a number that is divisible by, 3, 5, or both 3 and 5, respectively. When the number is not divisible by 3 or 5, the number itself should be returned. (function fizzBuzz () { for (i=1;i<101;i++){ if (i % 15 === 0){ console.log('FizzBuzz'); } else if(i % 3 === 0) { console.log('Fizz'); } else if (i % 5 === 0 ){ console.log('Buzz'); } else { console.log(i); } }; })(); AND THESE ARE ERRORS I GET EACH TIME......... THERE IS AN ERROR/BUG IN YOUR CODE Results: 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 FizzBuzz 61 62 Fizz 6 |
(1) (Reply)
Do You Know You Can Get Everything You Buy Online For Free / Web4africa Does Not Want To Activate My Domain / Abuja, Learn 2 Code n Develop cool Animations... DURING THE PUBLIC HOLIDAY.
(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. 6 |