Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

if statement If the s

We've updated our previous CheckSpeed method to return a string value. Update the method body with this logic:

If the speed parameter is over 65, return the string "too fast". If the speed parameter is under 45, return the string "too slow". Otherwise, return the string "speed OK".

Steven Parker
Steven Parker
231,236 Points

Please give it your best "good faith" try, and then post your code along with the question (and a link to the course page) if you need help.

// YOUR CODE HERE if(speed > 65) { return "too fast"; } else if(speed <45) { return "too fast"; } else { return "speed OK"; }

2 Answers

Heaven forbid you type ok in lieu of OK...makes you feel dumb for about two minutes

Nuno Reis
Nuno Reis
23,956 Points

Lol, thanks for this comment! Got bitten by the same "mistake".

Steven Parker
Steven Parker
231,236 Points

The suggestion by Tineyi is very close! Except for this part:

else if (speed <45) { return "too fast"; }

I think you meant for this test to say "too slow" instead.