₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,279 members, 8,444,772 topics. Date: Tuesday, 14 July 2026 at 01:39 AM

Toggle theme

Enygma's Posts

Nairaland ForumEnygma's ProfileEnygma's Posts

1 (of 1 pages)

ProgrammingRe: Andela Lab Solution(fizzbuzz) by Enygma(op): 9:40pm On Jun 25, 2016
Woww, I appreciate you all. Got it guys,you made it possible. Thanks
ProgrammingAndela Lab Solution(fizzbuzz) by Enygma(op):
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.........

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)
WebmastersAndela Lab Solution(fizzbuzz) by Enygma(op):
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]
WebmastersAndela Lab Solution(fizzbuzz) by Enygma(op):
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 (of 1 pages)