Got a problem in executing these following codes


#1

var red = [0, 100, 63];
var orange = [40, 100, 60];
var green = [75, 100, 40];
var blue = [196, 77, 55];
var purple = [280, 50, 60];

var myName = "mae";

if(15 < 5) {
bubbleShape = "circle";
}

else {
bubbleShape = "square";
}

letterColors = [red, orange, green]

drawName(myName, letterColors);


#2

Try using var letterColors = ["red", ''orange'', ''green'']
var drawName(myName,letterColors);


#3

@rodjer45, the red, orange, etc. are variables not strings, so they are correct without the " ".

@scriptslayer99461, what error message are you getting with that code?


#4


#5

Oops, try again. Write an if/else statement that makes the bubbles circle-shaped. Adapt the if/else statement from the the example on the left.


#6

The way that you've structured your if/else means that the bubbles will be square shapes. If this is your first try at JavaScript then you might find the following example useful.

This is how if/else statements work:

    if (this is true) {
        do this thing;
    } else {
        do this other thing;
    }

Let me know if you can see how that works.


#7

I've put "" already but, still doesn't work..


#8

Your " " were already perfect.


#9


#10

still have an error!! what should i do??


#11

I wasn't kidding when I said that your

letterColors = [red, orange, green]

was already perfect. Putting " " on those colour variables is changing them from variables to strings -- you do not want to do that.


#12

if(15 < 5) {
bubbleShape = "circle";
}

else {
bubbleShape = "square";
}


#13

how about that one? is it correct?


#14

In English, your if/else statement says:

    if (15 is less than 5) {
        make circles
    } else {
        make squares
    }

What do shape do you think that you will get from that?


#15

the result of that is squares


#16

Yes it is.

You can change any of these things to get the outcome that you want:
- (15 is less than 5)
- make circles
- make squares

You get to decide! :slightly_smiling:


#17

okey got it.. thank you for your help!!


#18

Good work!

If you have time, you can have more fun making new colors :slightly_smiling:


#19

okey!! I'll try that one.. thanks!!!