FAQ: Welcome to Codecademy! - Multiple Colors

This community-built FAQ covers the “Multiple Colors” exercise from the lesson “Welcome to Codecademy!”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development
Code Foundations

Welcome to Codecademy!

FAQs on the exercise Multiple Colors

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

23 posts were split to a new topic: How is the Color Spectrum Defined?

so i was doing the code foundations practice and i backspaced all of the coding and retyped it in the exact same format to see if i could run one on my own but when i press ‘run’ nothing happens. but if i paste the original text it works even though what i typed was the EXACT same. someone help me understand this?

1 Like

do we have to learn or remember colour codes for coding?

We use color codes in CSS, but when we consider that JS is joined at the hip to CSS, we should be able to manipulate the style sheet, and if that means changing colors, then one may conclude we should know how CSS works with colors. As for remembering color codes, that isn’t necessary. There are lots of resources (color wheels, color pickers, theme pickers) online if we need to dial in a particular color.

All we really need to understand is how RGB colors are set which is covered in CSS.

2 Likes

Why in the theory the variable letterColors defined with keyword var and in the editor without ? other variables too.

A post was split to a new topic: Variables and functions

I am a little bit confused as in what i need to do ? can someone please help

We’re a little disadvantaged since we do not know what lesson you are on. Please post a link to the exercise in a reply so that we can share in the narrative.

Hello @ajax8271723038 and welcome to the Codecademy Forums!

This exercise asks you to experiment by changing the numbers inside the square brackets on lines 2 to 6.

For example, you could change

red = [0, 100, 63];

to

red = [20, 167, 98]

The hint provided in this exercise will help as well.

Exercise Link: https://www.codecademy.com/courses/welcome-to-codecademy/lessons/welcome-to-codecademy/exercises/multiple-colors

I’ve had similar things happen where pasting script runs yet manually typing in the right code yields an error message .

Hello! How does the DrawName function know that each letter should be assigned one colour in the list in that order? Is it got to do with the way that DrawName function was programmed? If so, would it be possible to change the way a function is programmed to say make every two letter the same colour? Thanks

Without seeing the actual code, you bring up a list, which order is followed by the program. That would suggest we could adapt the list to contain the colors we choose. Copy and comment the list and paste it in again. Now change the colors to be alternatively the two colors you wish to use. There would be nothing else to change in the code if this is actually the case.

1 Like

Hi,

I’ve just started this exercise and am completely new to coding, but I was really curious about changing some of the color numbers to “null”. I honestly didn’t expect anything to happen but for some reason the color line with "null"in it takes the color of the previous color. So for example:

red = [0, 100, 63];

orange = [40, null, 60];

green = [75, 100, 40];

blue = [196, 77, 55];

purple = [280, 50, 60];

I changed Orange’s saturation number (If i’m going of the explanation that the colorscheme goes by HSL notation; H for hue is the ‘which’ of color, S for saturation means how ‘colored’ the color is, and L for luminance/V for value defines how ‘bright’ the light is (the two are defined slightly differently). source: [arraysurfer35729] comment on: How is the Color Spectrum Defined? ) to “null”. Now the originally orange letters turn red! If I now change Blue’s “hue” number to null the blue letters turn green! etc etc. If I now turn any one of green’s numbers to “null” both blue’s and green’s letters turn red as well etc etc.

Maybe this gets explained later on in the course, but does anyone know why that is? I thought "null’ was like a non existing variable, a literal empty or nothingness.

null is an object, so not ‘non-existing’, that would be undefined, which is not an object. it is also not an expected input for the HSL function. JS is a very determined language so will just do whatever it can to complete its task. I suspect it will cast null to 0 since it fits the expectations.

1 Like

Hi mtf,

Thanks for the explanation!

1 Like

I’m kinda confused in the way that Variables are typed out.
In this exercise the Variable uses whether as in the previous Variable uses ’ '.
code used:
letterColors = [red, orange, green, blue, purple];

message = ‘insert message’;

Why is the notation of the variable different?

Values can be of different data types.

message = 'Multiple colors!';

The above is assigning a string to the message variable. Single or double quotes are used to specify strings.
Numbers and booleans are among other primitive data types.

red = [0, 100, 63];
// ...
// ...
letterColors = [red, orange, green, blue, purple];

Square brackets are being used to assign an Array to the letterColors variable. Similarly, arrays have been assigned to the other variables such as red, orange etc. earlier in the exercise. Arrays are a type of Object which are non-primitive.

You can browse details about the data types here:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Language_overview#data_types

If you take a course on JavaScript, there would likely be a lesson(s) introducing you to some of the data types and their syntax.

1 Like

That actually makes so much sense (who would’ve thought).
Thanks a lot!

1 Like