10-18-17, 10:46 PM
Heres one that I solved before
Also answer to the ? I wrote)
var i;
var myNumber;
myNumber = prompt("Give me your number");
for (i=1; i<=myNumber; i++) {
if (i % 3===0 && i % 5 ===0) {
console.log("FizzBuzz");
}
//if the number is divisible by 3, write "Fizz"
else if (i % 3 === 0) {
console.log("Fizz");
}
//if the number is divisible by 5, write "Buzz"
else if (i % 5 === 0){
console.log ("Buzz");
}
//Otherwise, just write the number
else {
console.log(i);
}
}
(And before you accuse its a copy paste, No, its not on a webpage or forum and no my search history doesnt even have "Fizzbuzz copy paste" in it. I genuinely wrote and spent time on that to answer something as a challenge)
Also answer to the ? I wrote)Code:
//initialise variablesvar i;
var myNumber;
Code:
//Ask the user for a numbermyNumber = prompt("Give me your number");
Code:
// for the numbers 1 through to the number given,for (i=1; i<=myNumber; i++) {
Code:
//test the number for being divisable by BOTH 3 & 5if (i % 3===0 && i % 5 ===0) {
console.log("FizzBuzz");
}
//if the number is divisible by 3, write "Fizz"
else if (i % 3 === 0) {
console.log("Fizz");
}
//if the number is divisible by 5, write "Buzz"
else if (i % 5 === 0){
console.log ("Buzz");
}
//Otherwise, just write the number
else {
console.log(i);
}
}
(And before you accuse its a copy paste, No, its not on a webpage or forum and no my search history doesnt even have "Fizzbuzz copy paste" in it. I genuinely wrote and spent time on that to answer something as a challenge)
Login
Register
Current time: 6-3-26, 11:26 PM

Portal
Forum
Members
Calendar
Help


![[+]](https://lennyfacegaming.org/images/collapse_collapsed.png)