Playground missing colors


#1

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.

Thank You!


Problem with Code playground
Help with code playground
#2

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.

–Frankie


#3

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.


#4

Hi @Kruger,

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. :slight_smile:

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! :slight_smile:

Hope this helps! Feel free to reply if otherwise, and I’ll do my best to go more in-depth! :smile:


#5

To add to what @mysteryguy3039 has already said, the color variable looks a little like this:

var color = ['blue', 'red', 'orange', 'blue', 'green']

Have fun trying things out in the playground!
H :slight_smile:


#6

I am trying something which I was taught in the lesson ‘A dash of Random’ in the code playground but the code won’t run.grasshopper


#7

Hi @kunalverma,

You’re using the literal text 'color', not the keyword color. It should look like this:
drawBox(pickRandom(color));

Also, in your drawBoxes(), the meanings of the letters are pre-defined by the Code playground, which means that the var x and var k won’t do anything.

–Scott.


#8

Hey @kunalverma,

You’ll need to create the variable color in order to replicate the code from A Dash of Random. You’ll probably find the answers in this thread useful.

H :slight_smile: