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

banner
Close banner
0 points
Submitted by deanskee
about 10 years

12/15 [resolved] Decisions Decisions

Im confused about the If and else statement in the example… What does the 10<3 pertain to… Is it the numbers in the arrays? Why choose 10 and 3? Why can’t it be

If you could explain the reason behind those random numbers and what they pertain to/ why those numbers… that would greatly be appreciated. Thanks

Answer 53321f8452f863c8560023a4

0 votes

Permalink

Hi Dean,

Here is how if/else statements work:

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

In the example in the exercise, the (10 < 3) is nothing special, except for the fact that it is false. that will cause your if/else statement to “do this other thing”. If you want it to “do this thing” then you will need to make sure that what is in the ( ) is true.

There are endless expressions that you could put in the ( ) that will be true. Here are a few examples:

1 === 1
1 <= 20000
1 != 42
"Dean".length === 4
true
!false

Have you been through the JavaScript Track exercise where they explain Comparison Operators yet?

points
Submitted by Judy
about 10 years

Answer 53335aa18c1ccc825c0001f9

0 votes

Permalink

That does not help

points
Submitted by BunnyLover245
about 10 years

1 comments

Judy about 10 years

Tell us what sort of help you need BunnyLover.

Answer 5334bb799c4e9dfa65000db7

0 votes

Permalink

Hi Dean,

I see that you have a working Animate Your Name codebit now so I have marked your question as [resolved] - good work!

points
Submitted by Judy
about 10 years