Help if/else conditions in one console.log

Hi, i have this code:
var i = 0
for (i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
console.log(“BugFizz”)

}
else if(i % 3 == 0) {
  console.log("bug")
}
else if(i % 5 == 0) {
  console.log("fizz")
}
else {
  console.log(i)
}

}

So I want to put only 1 console.log and print same text.

need to asiggn value in to a variable but don’t know how

@csalva is this what you mean?

var i = 0, result;
for (i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
result = 'BugFizz'

}
else if(i % 3 == 0) {
  result = 'bug'
}
else if(i % 5 == 0) {
  result = 'fizz'
}

}

console.log(result)

hey, thanks for your answer

It looks like what i want but need print in console all numbers (1 to 100 ), in your answer only show result, need to add “i” variable

edit: just your variable is global, need put in the end of the for loop. So still when run console, print 3bug i need only “bug”

you can mode the declaration of result inside the loop, and initialize it as value of i
and if you put the console.log inside the loop it should be what you want