简体   繁体   中英

// * Use a `for-loop` to increment `726` with the value `4`, `17` times

// * Use a for-loop to increment 726 with the value 4 , 17 times.

My Code

var sum = 726;
var i = 0;
for(var i; i <= 17; i+=4) {
    
     document.write(sum + i + "</br>");
 }

It increments only 5 times with my code, I need it to increment 17 times. Im stuck, can someone help me out?

Here you can do this.

You can increment your sum += 4 in every loop.

I have removed i <= 17 to i < 17

So that loop will run for 17 times

var sum = 726;
for(let i = 0; i < 17; ++i) {
    console.log(sum+=4)
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM