Rainbow Hopper explainer

#6

So I can’t get this to run and complete and I’ve got no idea what I’m doing wrong. Anyone with any ideas?

0 Likes

#7

The first line of code: var location = 0; creates the location variable and then sets it equal to 0.

Inside your drawSquare function declaration, you use the var keyword again. That means, create a new variable called location which overwrites your old location. If you remove that line and instead start by adding the location identifier, you can write out: location = location + 30; This uses the existing location variable instead of trying to create a new one each time the drawSquare function runs.

–Frankie

3 Likes

#8

Still, i m unable to crack this puzzle, pl help

0 Likes

#9

Should be location= location + 30
:slight_smile:
JavaScript is case sentive .

2 Likes

#10

Still not solved bro

0 Likes

#11

You have the variable called Location at the top but its not got a capital when used in the delay(), so you need to change that to be: delay(17 * Location).

Give that a try and let me know.

~Jon

1 Like

#12

Hi! I can’t solve this puzzle. Need help! Thanks!

0 Likes

#13

Hi,

Your jump() function call and location update are not inside of the drawSquare function definition. If you move these 2 lines of code inside of the curly brackets {} then they will run each time drawSquare() runs.

Simply tap above the }; and re-type jump() and location = location + 30. You should see the commands get indented to indicate they are inside the brackets.

–Frankie

2 Likes

#15

So I passed the test, I got it to run really good. The thing is that the first box starts after one empty box space, not from the beginning. Why is that?

0 Likes

#16

Got it nevermind. I added another location=location+30 outside the drawsquare function

0 Likes

#17

While that will work, it SHOULD start with a lower-case letter. Every language has coding conventions, which make it easier for others to understand what you write, and the convention for JavaScript is for variables to start with lower-case letters.

–Scott.

0 Likes

#18

Very true, and its a good thing to point out - and I probably should have done so too.

I’m not actually aware if the app mentions it as a coding convention though, so I thought it best to simply point out the place where the case of the variables didn’t match, as others had mentioned the case sensitivity.

~Jon

0 Likes

#19

Dis is da way to do

1 Like

#20

its bugged or what… cant solve it

0 Likes

#21

You’re running into the same hiccup some other people have seen. If you remember the Ukraine to Haiti puzzle, you don’t need to use the var keyword if you’re just updating an existing variable value. var is only needed when creating a new variable.

–Frankie

0 Likes

#22

I need help with rainbow hopper

0 Likes

#23

Hi,

Have you looked at the explainer page?

–Frankie

0 Likes

#24

How come the delay doesnt get longer if delay is 17 * 30 and then *60, *90…?

0 Likes

#25

The delay actually does get longer, the reason the animations seem to be evenly spaced is because they all start their delay timers at about the same time. When you run the code, each drawSquare() runs right after the previous one; the whole thing probably takes less than a millisecond.

red:    17*0   =  0ms
orange: 17*30  =  510ms
yellow: 17*60  = 1020ms
green:  17*90  = 1530ms
blue:   17*120 = 2040ms
indigo: 17*150 = 2550ms
violet: 17*180 = 3060ms

The “17” multiplier is used to get the delay close to 0.5 seconds per box. A more precise number would be 16.666…

–Frankie

0 Likes

#26

I Couldn’t get to write or tap the colors and blank space in the a draw square box please I Need Help. I Don’t Know What I Am doing Wrong

0 Likes