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

Conditionals and Control Flow Forum

View Course » View Exercise

1220 points
4fd240d1dfc41e000301180b_894996853
Submitted by
John Aten
about 4 years ago

"Did you remember to include the else keyword?"

I'm totally stumped on this one. I can't find anything wrong with the code:

<?php
        $items = 6;    // Set this to a number greater than 5!
        if ($items > 5) {
          echo "You get a 10% discount!";
        } else {
          echo "You get a 5% discount!";
        }
      ?>

But I keep getting:

Oops, try again. Did you remember to
include the else keyword?

I've tried resetting the editor several times, rewriting the code, comparing it to the example. I even tried replacing "echo" with "print," but nothing works. What am I missing?


3 votes

permalink

I pasted your code into my window and it passed.

You should also try reloading the page in your browser and trying it in a different browser.

1991 points
4f74a61860cd570003003e72_283945339
Submitted by
Julia Toos
about 4 years ago

1 Comment

4fd240d1dfc41e000301180b_894996853 John Aten about 4 years ago

That worked. I just went back to the page, pasted it back in and hit submit, and it was good to go.


1 vote

permalink

It worked for me too.
I copied your code and I pasted it in my worksheet.
It worked a lot.
It was not faulty, maybe you should try using it on Google Chrome or another browser.

111 points
54b28f13a46e7abc2eae1cdc9ddcd0fa?s=140&d=retro
Submitted by
Creativeexcel
about 4 years ago

3 Comments

52701995abf821fec000040d_918489277 Kamran Mackey about 4 years ago

I don't think you are allowed to be on Codecademy when you are 8, sorry.

5414acdb7c82cabe06002b33_753853944 Aaron about 4 years ago

I am not sure of that, I am only 10 and I do it, plus it's better to learn young.

58a08665e1281377b20000c5_197143557 Excel almost 4 years ago

I am that same Creativeexcel and my mom knows I am on Codeacademy.


0 votes

permalink

i have the same code .,my browser is google chrome i am geting the following error
Oops, try again! Did you set your else statement to echo or print 'You get a 5% discount!' ? Don't forget your semicolon at the end!

97 points
67814d94f29902445868c8645b05533b?s=140&d=retro
Submitted by
sainandan
almost 4 years ago


0 votes

permalink

This code work for me

<?php
$items = 5;

    if($items > 5) {
      echo "You get a 10% discount!";
    }
    else {
        echo "You get a 5% discount!";
    }

  ?>

483 points
535369f952f8637c18000abc_296617412
Submitted by
Anthony Souza
about 3 years ago


-7 votes

permalink

Honestly I don't get it my onlu mistake was to use 10 instead of 6 ... what the **** dude? lol

Edited by : Maciej Wiercioch removed inappropriate language

334 points
5145223915b4a733c300217f_366219676
Submitted by
Alex Liebert
about 4 years ago

3 Comments

54b28f13a46e7abc2eae1cdc9ddcd0fa?s=140&d=retro Creativeexcel about 4 years ago

Never mind. I am only 8 years old. I was only trying to help. :) :) :)

5414acdb7c82cabe06002b33_753853944 Aaron about 4 years ago

Yeah you shoud not use bad language on this site.

501b38f19d5d0e0002022ced_397299968 radster01 about 4 years ago

your flagged