I am trying to understand the difference between these two ways of writing the loop. the resulting for both code snippets is different . Why?
- for loop : output variable is inside the loop , gives different result. - for (var n = 1; n <= 100; n++) { var output = ""; if ( n % 3 == 0) output += "Fizz"; if (n % 5 == 0) output += "Buzz"; console.log(output || n); }
- for loop : output variable is outside the loop , gives different result. - var output = ""; for (var n = 1; n <= 100; n++) { if ( n % 3 == 0) output += "Fizz"; if (n % 5 == 0) output += "Buzz"; console.log(output || n); }
 
    