Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
7

Complete the function fizzBuzz in the editor below.

Carderalli
Carderalli

Given a number n, for each integer i in the range from 1 to n inclusive, print one value per line ad follows:

  • if i is a multiple of both 3 and 5, print FizzBuzz.
    -if i is a multiple of 3, but not 5, print Fizz.
    -if i is a multiple of 5, but not 3, print Buzz.
    -if i is not a multiple of 3 or 5, print the value of i.

FUNCTION DESCRIPTION
fizzBuzz has the following parameter(s): int n: upper limit of values to test (inclusive)
Returns: NONE
Prints:
The function must print the appropriate response for each value i in the set {1, 2, ..., n} in ascending order, each on a separate line.
CONSTRAINTS 0< n < 2 x 10^5

INPUT FORMAT FOR CUSTOM TESTING
Input from stdin will be processed as follows and passed to the function.
The single integer n, the limit of the range to test: [1,2, ...,n].

3 years ago

Voters

Comments

TopNew
2
Vandesm14
Vandesm14

What have you tried so far? I can't help you if you don't try it yourself first.

3 years ago
1
Carderalli
Carderalli

function FizzBuzz(i){
(var i = 1; i <=15; 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)
}@Vandesm14

3 years ago
2
Carderalli
Carderalli

Hint: hit control+c anytime to enter REPL.
/home/runner/index.js:34
(var i = 1; i <=15; i++) {
^^^

SyntaxError: Unexpected token [email protected]

3 years ago
3
Vandesm14
Vandesm14

@Carderalli
You forgot the for loop: for (var i = 1; i <=15; i++) {

3 years ago
1
Vandesm14
Vandesm14

@Carderalli

Please mark my comment as the answer if I resolved your issue 👍

3 years ago
1
gregory54
gregory54

Your blog has chock-a-block of useful information. I liked your blog's content as well as its look. In my opinion, this is a perfect blog in all aspects. เว็บ พนัน อันดับ 1

3 months ago
Load more