This forum is now read-only. Please use our new forums at discuss.codecademy.com.

For Loops in PHP Forum

View Course » View Exercise

721 points
272d27d72a2f7fd052716eca1ef8cff0?s=140&d=retro
Submitted by
ArronStone_521cb9f0548c35abc900012b_
about 4 years ago

What's wrong with this code?

for ($a = 50; $a >= 5; $a = $a - 5) {
      echo $a;
  }

0 votes

permalink

Nothing. Just copy the code, refresh the page, and paste it. Worked for me.

471 points
8aa9ca3a173cb6d7a7ef8406f991e3e3?s=140&d=retro
Submitted by
Wolfmans55
about 4 years ago

1 Comment

Picture Aaron Weiss almost 4 years ago

I had to change the second element from "$a >= 5" to "$a >= 1". The result is the same, of course, but the SCT didn't like it the first way. No idea why.


0 votes

permalink

for ($a = 50; $a >= 5; $a = $a - 5) {
echo $a;
}

"$a =" at the end seems unnecessary. Overall, the code works fine.

418 points
5238f47babf821a2d10008cd_410759937
Submitted by
Sean Do
about 4 years ago