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 trialRasmus Flomén
3,193 PointsHelp! Code challange "Convert the if/else to a ternary if statement."
Hi, what am I missing?? I get the error "Bummer! Did you include the boolean expression to evaluate" I dont relly understand what is wrong.
int value = -1;
string textColor = null;
(value < 0) ? textColor = "red" : textColor = "green";
2 Answers
Jennifer Nordell
Treehouse TeacherFirst we say what variable we're looking at, then we give the expression to evaluate. You've got it a little backwards here.
textColor = (value < 0) ? "red" : "green";
If the value is less than 0 the textColor is set to red, otherwise it's set to green. Hope that's helpful!
Jesper Henriksen
3,308 PointsThis made me realize that my only error was actually a typo in "green" :D Thank you for the assistance!
Rasmus Flomén
3,193 PointsRasmus Flomén
3,193 PointsThank you Jennifer for the help :)
Luis Santos
3,566 PointsLuis Santos
3,566 PointsI was a bit confused with what the instructor explained on the video and what you actually did. I thought I understood the challenge at length but kept getting a bummer message requesting a Boolean expression. Thank you for the easy explanation, Ms. Nordell.
Simbarashe Chikaura
8,979 PointsSimbarashe Chikaura
8,979 PointsThanks. But i think the real problem here is how Treehouse expects us to know this sort of thing without sufficient knowledge from the previous material, videos, etc. This isn't the first time I've had to search for a solution out of frustration. The teaching methods aren't intuitive to the learner. Well, in my opinion, at least.