oliver Bergman oliver Bergman - 14 days ago 6
Javascript Question

Not getting any output with Javascript code

I need some help with this problem.

Exercise:


  • Use a for-loop to increment 399 with the value 8, 13 times.



My Code so far.

var a = 399;
var b = 8;

for (i = 0; i < 13; i++) {
a += b;
}
ANSWER = a;


When I run it I don't get any output.

What should I do in order to get the output?

Answer

Your code is fine, and in order to output the result, add this after the for loop:

Display in browser console

console.log(a);

Display a blocking alert

alert(a);

Here's a demo with alert():

var a = 399;
var b = 8;

for (i = 0; i < 13; i++) {  
  a += b; 
}

alert(a); // output it