Javascript
I need help please, i started my javascript career with Eloquent Javascript and bumped into this problem. I was asked in an exercise to write a loop that displays numbers from 1 - 100 in the console. now, i was asked to replace that were divisible by 3 with "Fizz" and those divisible by 5 with "Buzz" So i wrote this code: <script type="text/javascript"> for(var num=1; num <= 100; num++){ if (num % 3 ==0) { console.log= "fizz"; } if (num % 5 ==0) { console.log= "buzz"; } console.log(num); } and got it wrong. Now this was the solution: <script type="text/javascript"> for(var num=1; num <= 100; num++){ var output=""; if (num % 3 ==0) { output += "fizz"; } if (num % 5 ==0) { output += "buzz"; } console.log(output || num); } But a dont understand why they had to create a variable with an empty string and the rest of the flow with that output variable confuses me. I need your help please.