Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,434 members, 7,819,567 topics. Date: Monday, 06 May 2024 at 06:17 PM

Andela Lab Solution(fizzbuzz) - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Andela Lab Solution(fizzbuzz) (733 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)

Good Web Developer Needed For A Project / Get A Custom Website For As Low As 5k (check Thread For My Portfolio) / I Caught An Adsense Scammer

(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. 9
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.