Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,156 members, 7,807,522 topics. Date: Wednesday, 24 April 2024 at 02:40 PM

Andela Lab Solution(fizzbuzz) - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Andela Lab Solution(fizzbuzz) (583 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:10am On Jun 25, 2016
Hello everyone, I need you guys to look into this code for me. I have completed 93% of the Andela Homestudy,I need your urgent help on this, thanks!

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.


MY Solution
(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 THE ERRORS I GET EACH TIME.........

[b]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
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz

/home/ubuntu/Applications/andelabs-server/tmp/andelabs_5765ac22e83de519007349fd_565c28fd9c306a14009680f2.js:21
module.exports = fizzBuzz;
^
ReferenceError: fizzBuzz is not defined
at Object. (/home/ubuntu/Applications/andelabs-server/tmp/andelabs_5765ac22e83de519007349fd_565c28fd9c306a14009680f2.js:21:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/ubuntu/Applications/andelabs-server/tmp/5765ac22e83de519007349fd-565c28fd9c306a14009680f2-test.js:1:78)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
[/b]

(1) (Reply)

I Need Review Of This Blog Plz / Adsense Earning Trick For Sale $36 / 5 Best Wordpress Blog Theme

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