Part 5 in how do you do-while


The second coin game:

The text says that is would stop at "H", but it actually does stop at "T".
I did start writing in the script and now it crashes over and over again.


Can you post your code so i can check it?


The only thing i changed was the line:
if ($flip = 1){

Before is was:
if ($flip){

$flipCount = 0;
do {
    $flip = rand(0,1);
    $flipCount ++;
    if ($flip = 1){
        echo "<div class=\"coin\">H</div>";
    else {
        echo "<div class=\"coin\">T</div>";
} while ($flip);
$verb = "were";
$last = "flips";
if ($flipCount == 1) {
    $verb = "was";
    $last = "flip";
echo "<p>There {$verb} {$flipCount} {$last}!</p>";


that is where you made a mistake:

if ($flip = 1){

you assign a value of one here to $flip, so now this line:

while ($flip);

will always be true (since $flip is always one, which is true)
you want to compare:

if ($flip == 1)

you should use two equal signs. You could just have left it the way it was, 1 is true, and 0 is false so if($flip){ would have been fine


Yes, but I can't change anything. They give me directly a:

"Something went wrong :frowning:
Click Close to try again or refresh the page."

Even the reset code option doesn't work after that.


Did you refresh the page? Did you re-open the page?


I have tried to refresh it alot (f5 key). closing and reloading the page does not help either.


Then i am out of ideas, you could try a different browse all together


Opening it in another browser made the page forget my previous changes at the not completed sesions.

Thank you for your time.