Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[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.


Mod edit: Please do not request solutions. The purpose of this board is to assist people with their code. Simply providing solutions is counter productive to the learning process. There are many people here willing and able to assist you with your code but we do not just give the answers. Thanks.


Sorry @gcxyshiyu , no-one is allowed to give working code to someone else.

If you’re having trouble with this level, do these things:

  • Make a new topic with a clear title stating your problem. For example: I’m having trouble with the level Dance-off.
  • Post your code formatted as stated in the
  • State what you’re having difficulties with.


:lion: :lion: :lion: