Hi,
I’ve a questions regarding the playground. Not sure if I’m doing something wrong or there actually is no colors available to choose from when practicing the drawbox function.
I’m new to this and hence clueless as to where to ask these questions.
I do apologize if this is not the correct way.
You’re correct. The colors that you use in the early puzzles are actually just variables that store a string with the same name. For example, var red = 'red'; will create a red button and var blue = 'blue' will create a blue button that you can insert into a drawBox().
You can also just write the color directly into drawBox() using a string drawBox('yellow'). But an advantage to using the identifier is that you won’t have any spelling mistakes as long as you typed the color correctly when creating the variable.
I just started using the app and to practice what I learnt, I went to the code playground. I got frustrated because I want to use the drawbox(pickrandom(color)) function but the keyword color is not in the available keys nor would it let me enter it manually. I know I may have just missed something so a little nudge to the right direction is most welcome.
I believe color was one of the variables they made hidden to not look overwhelming in the app. In the playground, you get to define it yourself.
You just need to create an array of strings named ‘color’ and include several different color possibilities inside the array. Then your code will run flawlesly!
Hope this helps! Feel free to reply if otherwise, and I’ll do my best to go more in-depth!