[SOLVED] Dance-off Please help JS


#1
// Move in sync with your dance partner to impress Pender Spellbane.
while(true) {
    var friend = hero.findNearest(hero.findFriends());
      if(hero.distanceTo(friend) < 7) {
        hero.moveXY(friend.pos.x, friend.pos.y + 6);
    }
}

Hey guys. Can someone please tell me what am I doing wrong here?
Thanks!


#2

that doesn’t complete the level.


#3

or, take out line number 4.


#4

I know.
I have no idea what to do.


#5

Seriously. Somebody?


#6

You have to put var friend = hero.findNearest(hero.findFriends()); outside the while-true loop, that’s it.


#7

I like your profile picture, it’s cool.


#8

Man! Thank you!! :slight_smile:
But can you explain why it wasn’t working with variable inside the loop?

Ahaha. Fan of Matrix?


#9

It’s because it carries on getting looped so when you were near another person who wasn’t you dance partner your nearest friend became that person and you went to their yPos + 6.
I haven’t watched the Matrix but I want to, I’ve seen the lobby scene and the scene where he dodges the bullets and gets shot in the legs. :sob: But yeah, I wanna watch it a lot I also want to watch the x-files.


#10

Makes sence. Thanks o lot!!

What stops you from it? Go and watch :slight_smile:


#11

I will watch it I think but we don’t have it and I’ve only just recently started to want to watch it but hopefully I’ll be able to get it from a library or something like that.


#12

what exactly do you need help with?


#13

I’ve solved it already. Thanks.