Reindeer Wakeup Javascript Help (Solved)

// This array contains the status for each reindeer.
var deerStatus = [
    "asleep",
    "asleep",
    "asleep",
    "asleep",
    "asleep"
];
// And this array contains our reindeer.
var friends = hero.findFriends();
// Loop through the reindeer and find the awake ones:
for (var deerIndex = 0; deerIndex < friends.length; deerIndex++) {
    var reindeer = friends[deerIndex];
    // Reindeer with y position > 30 aren't in a pen.
    // If so, set the reindeer's entry to "awake".
    if (reindeer.pos.y > 30) {
        deerStatus = "awake";
    }
}
// Loop through statuses and report to Merek.
for (var statusIndex = 0; statusIndex < deerStatus.length; statusIndex++) {
    // Tell Merek the reindeer index and its status.
    // Say something like "Reindeer 2 is asleep".
    hero.say(reindeer + "is" + deerStatus);
}

The hero says the reindeer’s name not number and the herder wants the number.
What should I do to make the hero say the number?
Thanks

2 Likes

change this:

to this:

hero.say(reindeer + "is" + deerStatus[statusIndex]);
4 Likes

sorry for a lot of edits

3 Likes

Now it hero says “vixen is undefined” @Anonym

2 Likes

oh, I forgot change to this:

hero.say("Reindeer" + statusIndex + 'is' + deerStatus[statusIndex])

like, you also need to say his number

I added that. Now however, the hero says the name but says letter of awake at a time. ex: “reindeer 0 is a”

@Anonym Are you there?

Im here. I have to ty to load up the level, but I may have not done it yet in javascript. Can you post your updated code? Make sure that all of your type errors are fixed (like spelling mistakes and so)

1 Like
// This array contains the status for each reindeer.
var deerStatus = [
    "asleep",
    "asleep",
    "asleep",
    "asleep",
    "asleep"
];
// And this array contains our reindeer.
var friends = hero.findFriends();
// Loop through the reindeer and find the awake ones:
for (var deerIndex = 0; deerIndex < friends.length; deerIndex++) {
    var reindeer = friends[deerIndex];
    // Reindeer with y position > 30 aren't in a pen.
    // If so, set the reindeer's entry to "awake".
    if (reindeer.pos.y > 30) {
        deerStatus = "awake";
    }
}
// Loop through statuses and report to Merek.
for (var statusIndex = 0; statusIndex < deerStatus.length; statusIndex++) {
    // Tell Merek the reindeer index and its status.
    // Say something like "Reindeer 2 is asleep".
    hero.say("Reindeer" + statusIndex + 'is' + deerStatus[statusIndex]);
}

Here is my code.

Sorry I have not done the level yet so I cant help you :sob:

2 Likes

Sorry, I cannot respond now.See you tomorrow, @sci12 !

1 Like

I looked at some other helps for this level and I changed that to this

        deerStatus[deerIndex]="awake";

Congrats on beating the level then I guess!

Thanks, if you need help you can @ me!

Congratilations, @sci12 ! :partying_face: :partying_face: :partying_face:

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.