12. Decisions, decisions: why does 10>3 matter?


#1

https://www.codecademy.com/en/courses/animate-your-name/2/6


I'm not getting any error messages, the code is fine: this is more of a "when will I use this in the future?" But I just wonder what the point is in adding if(10<3), an obviously true statement, which does nothing but be obviously true. Under what circumstances would I change that if/else? For example, wouldn't it be a better lesson to use an if/else like

if(myName>6){bubbleShape="circle"}
else{bubbleShape="square"}

So that "Meghanne" yields circles, but "Megan" would show as square?

Original code:

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 = "Meghanne";
letterColors=[red,orange,green,blue,purple]
if(10>3){bubbleShape="circle"}
else{bubbleShape="square"}

drawName(myName, letterColors);

#2

The true statement is just so it is guaranteed to show true, and make it circles vs squares, because 10 > 3 will always be True. :smirk:


#3

But I don't think I've really learned anything about why I would need to use the if/else function by merely entering a statement that will never affect the "else." Would I ever do this in any other situation? It makes else{bubbleShape="square"} a useless line of code.


#4

you could just have an if, remove the else and it should work fine?


#5

This is just a small project to lure you into wanting to learn more. Many things were glossed over and done for you behind the scenes. Take the JavaScript course to learn more about if/else and lots more. :grinning:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.