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# C# Objects Encapsulation and Arrays Ternary If

Hermes Crespo
Hermes Crespo
980 Points

Why am I getting the message: "Bummer! Did you include the boolean expression to evaluate?" if my code is correct?

Why am I getting the message: "Bummer! Did you include the boolean expression to evaluate?" if my code is correct? I am getting the message: "Bummer! Did you include the boolean expression to evaluate?" if it is obvious that I did use the boolean expression?

CodeChallenge.cs
int value = -1;
string textColor = null;

 string result = (value < 0) ? textColor = "red" : textColor = "green";

1 Answer

Steven Parker
Steven Parker
229,644 Points

The boolean expression is good, but there's some other issues:

  • the result of the ternary is being assigned to "result" instead of "textColor"
  • the ternary has assignments inside it instead of just the values