+ 1
Can't understand why 12?
var a =0; for(k=1;K<=2;K=k+1){ for(i=0;i<=5;i++){} a++; alert(a)}
33 Answers
+ 1
yes but he started with I=0
so the different values of I are :
0
1
2
3
4
5
break
so 6 values
don't forget to leave a like 😁👍
+ 1
but why 2*6 my second loop break when I=5
+ 1
@Kristina
Your code is not quite correct to get answer 12.
K variable is not same as k variable.
Second iteration i is do nothing (empty bracket).
The code can get output 12 is
var a =0;
for(k=1;k<=2;k=k+1){
for(i=0;i<=5;i++){
a++;}
}
alert(a);
// a has increment for 12 times (2 × 6)
+ 1
that code I meet here in challenge
+ 1
how
+ 1
go To view correct answers, go to your code and click on the bottom who is on the right top corner
if I was helpful don't forget to leave a like on my comments 👍😁
+ 1
like
+ 1
lav
+ 1
of course
+ 1
voch der
+ 1
Learjavascript karda
+ 1
ruseren
+ 1
Facebook kristina Hakobyan
+ 1
inchu
+ 1
DE harc ches tve js ic
0
Are you sure that the second } is before a++ ?
0
I think yes why?
0
because if it's before a=2 and if it's after a=12
0
if it's after is 12 while you do :
2x6 a++