This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Animate Your Name Forum

View Course

982 points
556744cd9113cb896500057e_977285472
Submitted by
Denys Matsevych
almost 2 years ago

12/15 [resolved] Don't understand if/else statement

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 = "Denys";
var letterColors = [red, green, blue]
if(15 > 3) {
    bubbleShape = "circle";
} else {
    bubbleShape = "square";
}
drawName(myName, letterColors);

What is mean 'if(15 > 3)' ?????


0 votes

permalink

Hi Denys,

if(15>3) means "if 15 is greater than 3".

It's a bit silly because it is always true so your shape will always be a circle. This is just a tiny, introductory project, so it is just to demonstrate that if statements exist and that you could use them to make choices about what happens next in your programs.

3691 points
55df2afa95e3787b9200005e_359368177
Submitted by
Judy
almost 2 years ago

5 Comments

556744cd9113cb896500057e_977285472 Denys Matsevych almost 2 years ago

Thanks! These "magic" numbers confused me.

55df2afa95e3787b9200005e_359368177 Judy almost 2 years ago

You're welcome!

Picture lindyswing almost 2 years ago

Why 15? Can it be any number?

55df2afa95e3787b9200005e_359368177 Judy almost 2 years ago

If you want circles, then you can put ANYTHING that evaluates to true in the ( ).

55c729a19113cbc62a000301_79166364 Zhongjun Thierry LIU almost 2 years ago

or otherwise just put bubleShape = "square"; yeah ?