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 trialMndp bnwl
856 PointsGetting error : "Did you define a constant for the magic string 'red'?"
Getting this error even though I've declared a constant variable for "red".
const int revenue = 125000;
string status = null;
private const string _red = "red";
private const string _yellow = "yellow";
private const string _green = "green";
private const int _smallRevenue = 100000;
private const int _largeRevenue = 150000;
if (revenue < _smallRevenue)
{
status = _red;
}
else if (revenue < _largeRevenue)
{
status = _yellow;
}
else
{
status = _green;
}
1 Answer
Steven Parker
231,269 PointsThe access modifier "private" should not be used outside of a class.
But there's one other issue as well. While it would make no difference to the compiler, the challenge apparently doesn't like the two spaces between the word string
and the variable name in your color declarations.
You might want to report that last one as a bug to Support.