// 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
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)
// 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]);
}