Intro to objects (Debug Needed)


#1


for (i=0; i<21; i++) {
    if(i === 3/) { 
        console.log("Fizz");
    }else if (i === 5/){
        console.log("Buzz");
    }else if (i === 3/, i === 5/) {
        console.log("FizzBuzz");
    }else{
        console.log(i)
    }
};


#2

There is quite a few things wrong here.

Firstly you need to console.log fizzbuzz first before you check if 5 and 3 are divisible by the number.

Secondly this is will cause a syntax error. You are meant to use the symbol % when checking if numbers are divisible. Instead you need to do this

num % 3 === 0

And finally why is there a comma here? Shouldn't it be &&?


#3

Oh yeah. Sorry, it's been a while since I have done math in java.
It works better now, but it won't print "FizzBuzz"


#4

Thank you for your help again, by the way.


#5

Most welcome. So your first if needs to check for fizzbuzz, it should look like this. Remembering that you should check for the lower of the two numbers first.

if (i % 3 === 0 && i % 5 === 0)


#6

if that doesn't work please past your updated code.


#7

It worked. Thank you!


#8

How would this be fixed? It's in the very next lesson.

var getReview = function (movie) {
switch(movie){
case (movie === "Toy Story 2"):
return("Great story. Mean prospector.");
case (movie === "Finding Nemo"):
return("Cool animation, and funny turtles.");
case (movie === "The Lion King."):
return("Great songs.");
default:
return("I don't know!");
}
};


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.