Quotes help make search much faster. Example: "Practice Makes Perfect"

Friday, December 7, 2012

LearnStreet Javascript Lesson 5 Exercise 7


//sample solution


/*The function isMultipleOf checks if the first number is a multiple of
the second number. For example, isMultipleOf(10, 2) returns true
because 10 is a multiple of 2. Don't worry about how it works.
If you're curious, read about the % operator in the description.*/

function isMultipleOf(firstNum, secondNum) {
    return firstNum % secondNum == 0;
}

function fizzBuzz(num) {
    //Your code below.
    if(isMultipleOf(num,3) && isMultipleOf(num,5)){
        return "FizzBuzz";
    } else if(isMultipleOf(num,3)){
        return "Fizz";
    } else if(isMultipleOf(num,5)){
        return "Buzz";
    } else {
        return num;
    }
}
//test
fizzBuzz(24);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts