I’m playing around with doing “fizzbuzz” for fun in several sandboxes like CodeSandbox and JSfiddle etc but I cannot get it to output to the console log for anything more than a basic 1+1. I just get errors saying:
/src/index.js: Unexpected token (17:25) 15 | return “”; 16 | } > 17 | }console.log(fizzbuzz()); | ^
browser
Parsing error: Unexpected token 15 | return “”; 16 | } > 17 | }console.log(fizzbuzz()); | ^ (null)
I realise I’m doing something fundamentally wrong but I can’t figure out for the life of me what it is.
function fizzbuzz(){
var three= i % 3===0;
var five= i % 5===0;
for (var i=1; i< 100; i++){
if (three && five){
return "fizzbuzz";
}else if (three){
return "fizz";
}else if (five){
return "buzz"
}else {
return "";
}
}console.log(fizzbuzz());
Can anyone advise, please?