This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Arnab
about 9 years

How do You pass This???????

**I put my code as this : 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 = “Arnab”; var letterColors = [red, orange, green]; if (1 + 1 = 2) { bubbleShape = “circle”; };

else { bubbleShape = “square”;

}; drawName(myName, letterColors);**

And it says Make sure you have defined all variables. It keeps saying it every time I try. How do you pass it????????

Answer 54e115de51b887275a007269

1 vote

Permalink

Hello Arnab :)

Semicolons are used to mark the end of a single instruction (like assignment instruction or function call), not a block of code (code enclosed between { }). So, we do not want semicolons after if or else.

Usually inside parentheses after if we place a boolean expression (statement which can be true or false). In math 1 + 1 = 2 is a valid, true statement, but not in JavaScript. This is caused by = character which is used only to assign. If you want to compare something you have to use comparison operator - ==.

Corrected 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 = "Arnab";
var letterColors = [red, orange, green];
if (1 + 1 == 2) {
    bubbleShape = "circle";
} else {
    bubbleShape = "square";
}
drawName(myName, letterColors);
points
Submitted by Maciej Wiercioch
about 9 years