0

I don't understand. Sum=0 then how sum=sum +6 is equal 16? Can someone explain?

I don't understand. Sum=0 then how sum=sum +6 is equal 16? Can someone explain?

23rd Apr 2019, 6:12 PM
Ицо Христов
Ицо Христов - avatar
18 Antworten
+ 1
Ama to ti si ot bulgariq
23rd Apr 2019, 6:33 PM
Ицо Христов
Ицо Христов - avatar
+ 1
Имаш loop който върти от i=4 до i<8 (т.е до 7), нали? Обаче вътре в тялото на loop-а има и условие. Ако i == 6, continue. Когато i == 6 да продължи директно със следващата итерация. Тоест имаш общо 3 итерации (i=4, i=5, i=7), а на всяка итерация увеличаваш sum с i. sum = 0 + 4 sum = 4 + 5 sum = 9 + 7 Накрая: sum = 16
23rd Apr 2019, 7:07 PM
Boris Batinkov
Boris Batinkov - avatar
+ 1
Благодаря!
23rd Apr 2019, 7:08 PM
Ицо Христов
Ицо Христов - avatar
+ 1
Type in English so that I can understand Boris Batinkov
23rd Apr 2019, 7:10 PM
Edwin
Edwin - avatar
+ 1
23rd Apr 2019, 7:25 PM
Edwin
Edwin - avatar
0
If there is a loop it will repeat Post the code
23rd Apr 2019, 6:21 PM
Edwin
Edwin - avatar
0
Can you paste the whole code? Most languages are case sensitive. So, 'Sum' is not the same as 'sum'.
23rd Apr 2019, 6:24 PM
Boris Batinkov
Boris Batinkov - avatar
0
It is the same code
23rd Apr 2019, 6:24 PM
Ицо Христов
Ицо Христов - avatar
0
I just can't understand
23rd Apr 2019, 6:25 PM
Ицо Христов
Ицо Христов - avatar
0
If sum = 10, then sum = sum + 6 would be equal to 16 (as number). But there is another way. If sum = "1", then sum = sum + 6 = 16 (as a string). Sum is always 0. That's why I'm asking for the whole code.
23rd Apr 2019, 6:32 PM
Boris Batinkov
Boris Batinkov - avatar
0
Yupp Boris Batinkov is correct
23rd Apr 2019, 6:34 PM
Edwin
Edwin - avatar
0
Tova v nqkakyv loop li se sluchva?
23rd Apr 2019, 6:35 PM
Boris Batinkov
Boris Batinkov - avatar
0
Ама то кода е там. Написан е във въпроса. Не разбирам как sum=0, а после като добавим 6 става 16
23rd Apr 2019, 6:40 PM
Ицо Христов
Ицо Христов - avatar
0
Къде го срещна това? Понеже е непълно. Имам предвид, че така представено го няма в никой език.
23rd Apr 2019, 6:47 PM
Boris Batinkov
Boris Batinkov - avatar
0
Като отидеш на JavaScript. Отиваш на Conditionals and Loops. След това на break and continue На последния въпрос (?)
23rd Apr 2019, 6:52 PM
Ицо Христов
Ицо Христов - avatar
0
Да токущо го видях.
23rd Apr 2019, 6:53 PM
Boris Batinkov
Boris Batinkov - avatar
0
He already told me, thanks
23rd Apr 2019, 7:11 PM
Ицо Христов
Ицо Христов - avatar
0
@Edwin, I'm sorry. It was faster to help him in Bulgarian. It's about the last question of JavaScript > Conditionals and Loops > break and continue > last queation (i remembered it): let sum = 0 for (let i = 4; i < 8; i++) { if (i == 6) { continue; } sum = sum + i; } document.write(sum);
23rd Apr 2019, 7:24 PM
Boris Batinkov
Boris Batinkov - avatar