0

Sololearn Crashes

Sololearn is crashing when I put in the course Web Development, in JavaScript part, the loop things. The Code is this: for (let i = 10; i <= 10; i+10) { console.log(i); } I tried three times and more, and stills crashing :(

2nd Nov 2023, 2:20 PM
Ringo
Ringo - avatar
10 Respostas
+ 4
রহস্যময়— পৃথিবী i = 10 10 <= 10 is True, so it will print 10 in the console. The system crash because i is not updated after the loop and create an infinite loop. OP doesn't say the expected output, so don't assume it will print 11, 12, 13 or 10, 20 and 30.
3rd Nov 2023, 1:37 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 4
The error in your code is in the for loop's condition and update statement. It should be i += 10 instead of i+10. Here's the corrected code: for (let i = 10; i <= 10; i += 10) { console.log(i); }With this change, your loop will run correctly and not cause crashes.
4th Nov 2023, 7:28 AM
ScriptMaestro 🇳🇬
ScriptMaestro 🇳🇬 - avatar
+ 3
After each loop it runs i+10, but it doesn't change the value of i.
2nd Nov 2023, 2:35 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 3
if still not working give feedback on info.sololearn.com
3rd Nov 2023, 12:12 PM
Alhaaz
Alhaaz - avatar
+ 3
It looks like there's a small mistake in your `for` loop. The condition `i <= 10` means that the loop will only run if `i` is less than or equal to 10. Since you're initializing `i` as 10, the loop won't run at all. Additionally, the increment statement `i+10` doesn't actually update the value of `i`. You might want to adjust your loop like this: ```javascript for (let i = 10; i <= 100; i += 10) { console.log(i); } ``` This loop will start `i` at 10, and as long as `i` is less than or equal to 100, it will increase `i` by 10 in each iteration and print out the value of `i`. If you continue to experience issues, you may want to reach out to SoloLearn support for assistance.
3rd Nov 2023, 1:14 PM
রহস্যময়— পৃথিবী
রহস্যময়— পৃথিবী - avatar
+ 2
Oh ok thanks
2nd Nov 2023, 2:32 PM
Ringo
Ringo - avatar
+ 2
sorry, bad advice. decrementing also gives infinite loop. use i+=10 or any number. but this will only give one output. Wong Hei Ming is right i +10 or i-10 does not change i, so you have infinite loop. i=10;i<=10 is just a bad idea...
3rd Nov 2023, 12:09 AM
Bob_Li
Bob_Li - avatar
+ 1
i = 10 i starts with a value of 10 i <= 10 i can never reach this value using i +10 so you have infinite loop. maybe you must use i - 10, or I -= 1
2nd Nov 2023, 11:42 PM
Bob_Li
Bob_Li - avatar
0
It seems like there's an issue with your loop code. The condition `i <= 10` will always be false since `i` starts at 10 and never changes. Additionally, the expression `i+10` in the loop increment section doesn't update the value of `i` as you might expect. If you're trying to create a loop that counts from 10 to 20, you could use this code: ```javascript for (let i = 10; i <= 20; i += 1) { console.log(i); } ``` This will correctly loop from 10 to 20, incrementing `i` by 1 each time. Try using this code instead and see if it resolves the issue. If Sololearn continues to crash, you might want to reach out to their support team for further assistance.
4th Nov 2023, 12:04 PM
রহস্যময়— পৃথিবী
রহস্যময়— পৃথিবী - avatar
0
Hello
4th Nov 2023, 1:39 PM