Creating color variables

We are doing CS Discoveries Unit 5 - Variables (Animation/gaming lab). The one lesson shows you how to create a color variable and call it. When the kids create their own color variables in another sub lesson it says they aren’t calling the variable. Why would that be.

Example:
var color1 = “tan”
fill(“tan”)

This should work, but it says the variable isn’t being called.

Not sure if I understand your problem, but if it’s that you get the error “color1 is defined, but it’s not called in your program”, then it can be fixed by calling color1 instead of hard-coding a value:

var color1 = "tan";
fill(color1);

It does not say it’s not defined. It says it isn’t being used, which is not true. I have kids that have the same code and it works for one but not the other. This is actually the first time I have ever had this occur on this particular lesson.

Sorry, I mistyped my question. I should have asked if you were getting this message:
image
In which case my code above will fix the issue, though sometimes that error message will appear even if that issue has already been resolved.

But if the same code crashes the program for some students and not for others, then it’s more likely a problem with the lesson and I can’t help you.

1 Like

@matthew.fundak,

Yes, @Binary_Coder is correct. You created the color1 variable and gave it a value of “tan”. To use the variable, you should reference the variable name color1.

If you are having issues with other lessons, post a shared link to the code and we’ll take a look to see why there may be an error.

~Michelle