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 trialBrittney Coble
16,474 PointsConstants code challenge - replace magic numbers and if, else if, else statements to constants
Perhaps I'm just tired but I am unsure of how to even approach this challenge and change the statements to constant variables.
Edit: I found the answer after a lot of digging through the community posts. Still, this question is just confusing to me. Working code for anyone else having issues:
const int revenue = 125000;
const int red = 100000;
const int yellow = 150000;
const string redColor = "red";
const string yellowColor = "yellow";
const string greenColor = "green";
string status = null;
if (revenue < red)
{
status = redColor;
}
else if (revenue < yellow)
{
status = yellowColor;
}
else
{
status = greenColor;
}