Anrk
07-23-2012, 09:56 PM
Having trouble passing the variables name age species and breed into function displayBadge from Pets.
Any help would be appreciated! Thank you in advance!:thumbsup:
species = prompt("What species of a pet did you bring today?",ES);
breed = prompt("What is the breed of your pet?",ES);
age = prompt("How many years old is your pet?",ES);
name = prompt("What is your pet's name",ES);
var competingPet = new Pet(name, age, species, breed);
competingPet.displayBadge();
function Pet(theName, theAge, theSpecies, theBreed) {
this.petName = theName;
this.petAge = theAge;
this.petSpecies = theSpecies;
this.petBreed = theBreed;
this.displayBadge = displayBadge;
}
function displayBadge() {
document.write(petName + " is a " + petBreed + " " + petSpecies +
" and is " + petAge + " years old.");
}
Any help would be appreciated! Thank you in advance!:thumbsup:
species = prompt("What species of a pet did you bring today?",ES);
breed = prompt("What is the breed of your pet?",ES);
age = prompt("How many years old is your pet?",ES);
name = prompt("What is your pet's name",ES);
var competingPet = new Pet(name, age, species, breed);
competingPet.displayBadge();
function Pet(theName, theAge, theSpecies, theBreed) {
this.petName = theName;
this.petAge = theAge;
this.petSpecies = theSpecies;
this.petBreed = theBreed;
this.displayBadge = displayBadge;
}
function displayBadge() {
document.write(petName + " is a " + petBreed + " " + petSpecies +
" and is " + petAge + " years old.");
}