[SOLVED] Dance-off Please help JS

// 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?


that doesn’t complete the level.


or, take out line number 4.


I know.
I have no idea what to do.


Seriously. Somebody?


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


I like your profile picture, it’s cool.


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

Ahaha. Fan of Matrix?


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.


Makes sence. Thanks o lot!!

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


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.


what exactly do you need help with?


I’ve solved it already. Thanks.