Your first while loop


#1

$number = 0;
while ($number <11){
echo "

{$number}

";
$number += 2;
}
Please tell me what is wrong with this code cause it seems infinite and I cannot go on. Currently I'm stucked in this exercise, please offer some help...

#2

Hi frentea you did some errors the right code is below
$number = 0;
while ($number <11){
echo
$number;
$number += 2;
}
number is a variable should not be between " ". Hope my answer will help you


#3

Thanks a lot!
But the system automatically run this wrong code every time I open it so there is no way for me to change the code. Is there any solution can stop the system running the code?
Meanwhile, I see in the hint the code is write like this:
$loopCount = 0;
while ($loopCount<4){
echo "

Iteration number: {$loopCount}

";
$loopCount ++;
}
I think the loopCount is also a number, but it writes in this way. So what is the right form for numbers?

#4

This code is correct and also you are right loopCount is a number. And I don't know why it run the wrong code.Close your browser and open to try and see.


#5

See this:


The console prints the right numbers but could not pass the exercise.


#6

Yeah i can see it. Can you give me the number of this lesson so I can test it on my side.


#7


#8

Hi, I changed the code to this and it worked. Amazing?


#9

Yes it's amazing because it should work in both cases . But the positive side is that you can now continue.


#10

Thank you for helping me this :slight_smile:


#11

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.