-3
function fizzBuzz (start, end) {
for ( var i = start; i <= end; i++ ) {
        if ( i % 3 === 0 && i % 5 === 0) {
            console.log(“fizzbuzz”);
        }
        else if ( i % 3 === 0) {
            console.log(“fizz”);
        }
        else if ( i % 5 === 0) {
            console.log(“buzz”);
        }
        else {
            console.log(i);
        };
    };
};

fizzBuzz (1,10);

Trying to execute FizzBuzz function. I thought it was a syntax issue, maybe I'm overlooking something fundamental?

  • 1
    Your quotation marks that you're using for the strings aren't the proper character. You have `“` and it should be `"`. – Lye Fish Aug 01 '15 at 04:33
  • You copy-pasted your code out of a source that allowed it's sample code to be broken. – Pointy Aug 01 '15 at 04:33
  • possible duplicate of [Codecademy FizzBuzz app, stuck on step 1](http://stackoverflow.com/questions/8797834/codecademy-fizzbuzz-app-stuck-on-step-1) – Andrew Savinykh Aug 01 '15 at 04:54

1 Answers1

0

It is a syntax issue:

function fizzBuzz (start, end) {
    for ( var i = start; i <= end; i++ ) {
        if ( i % 3 === 0 && i % 5 === 0) {
            console.log("fizzbuzz");
        }
        else if ( i % 3 === 0) {
            console.log("fizz");
        }
        else if ( i % 5 === 0) {
            console.log("buzz");
        }
        else {
            console.log(i);
        }
    }
}

fizzBuzz(1,10);

This is how it should look. You have unnecessary extra semicolons and wrong quotes, although only the latter truly broke your code.

eddyjs
  • 1,270
  • 10
  • 20