Having problems using console.log

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?

Your logged errors are because you’re missing a closing brace for fizzbuzz(). Also, var is no longer the preferred way to declare variables. If you won’t be changing what they point at, use const. Otherwise, use let. They have stricter scope and in this case will help you spot a logic error.

i is undefined here, so three and five will always be false. You need to create functions if you want to do that.

Also, a return statement will break from he function so you are actually getting a Value only for the first iteration of the loop, when i is 1.
This challenge usually asks you to print to the console, and just print i when it is not divisible by three or five.

There must be one more curly bracket which is missing:

}}console.log(fizzbuzz());