I keep getting a error password.toUpperCase is not a function. What am I doing wrong here?
// Move the hero and their pet to the exits.
auto onHear(auto event) {
// Get the volume and the password.
auto words = event.message.split(" ");
auto volume = words[0];
auto password = words[1];
// If the password should be loud:
if (volume == "Loud") {
// The pet repeats it in UPPER CASE.
pet.say(words[1].toUpperCase());
}
// If the password should be quiet:
if (volume == "Quiet") {
// The pet repeats it in lower case.
pet.say(words[1].toLowerCase());
}
pet.moveXY(pet.pos.x+ 24, pet.pos.y);
}
auto passDoor() {
auto guard = hero.findNearest(hero.findFriends());
auto password = guard.password;
// If the password should be loud:
if (guard.isLoud) {
// Use the .toUpperCase() method on the password and say it.
hero.say(password.toUpperCase());
}
// If the password should be quiet:
else if (guard.isQuiet) {
// Use the .toLowerCase() method on the password and say it.
hero.say(password.toLowerCase());
}
hero.moveXY(hero.pos.x+ 24, hero.pos.y);
}
int main() {
// Enable the pet to hear the guards.
pet.on("hear", onHear);
// The code for the hero to pass the doors.
hero.moveXY(10, 14);
passDoor();
passDoor();
return 0;
}