Question: (javascript) Have the function StringChallenge( num ) take the num parameter being passed and return all the numbers from 1 to num separated by spaces,

(javascript)Have the function StringChallenge(num) take the num parameter being passed and return all the numbers from 1 to num separated by spaces, but replace every number that is divisible by 3 with the word "Fizz", replace every number that is divisible by 5 with the word "Buzz", and every number that is divisible by both 3 and 5 with the word "FizzBuzz".

For example: if num is 16, then your program should return the string "1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16". The input will be within the range 1 - 50

Put/ implement the solution into this starter code below/KEEP the starter code (CODE also has be able to run through function call) :

function StringChallenge(num) {

// code goes here

return num;

}

// keep this function call here

console.log(StringChallenge(readline()));

Examples of inputs and expected outputs:

Input: 3 Output: 1 2 Fizz

Input: 8 Output: 1 2 Fizz 4 Buzz Fizz 7 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!