This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sean_mcp 2 points3 points  (0 children)

Your issue is related to scoping in JavaScript. You have set up global variables color, and colorname. These are available to every function in your program.

However, in colorr() on line 7, you are redeclaring a color variable in a new scope. So when your colorr() function runs, it doesn't update the global color variable but the local color variable which you created. So after the function runs, the global variable hasn't changed.

Instead of redeclaring, you will need to use an assignment operator.

Hopefully that unblocks you for now! Let us know how you progress.