function Dog (name, breed, weight) {
this.name = name;
this.breed = breed;
this.weight = weight;
this.bark = function() {
if (this.weight > 25) {
console.log(this.name + " says Woof!");
} else {
console.log(this.name + " says Yip!");
}
};
}
var fido = new Dog (“Fido”, “Mixed”, 38);
var fluffy = new Dog (“fluffy”, “Poodle”, 30);
var spot = new Dog (“Spot”, “Chihuahua”, 10);
console.log(fido.bark());
console.log(fluffy.bark());
console.log(spot.bark());
The issue, I am having is that I am unable to log this code using sublime text with Safari, chrome and firefox. It works when i use a web inspector but it comes up with an undefined value after each log. It also works when I use alert in the method instead of console log and change the function call at the bottom with fido.bark(); etc but the undefined value still comes up but this time only once.
Replace the quotes again. Notice that they are not recognized as string. Their color must be red. That is, “Fido” is not same "Fido"
When you write var variableX = 1000;, the browser console returns undefined. This behavior is normal. If you write variableY = 2000;, then browser console returns 2000.
Thanks a lot guys! But it looks like both of my current browser are malfunctioning and aren’t rendering the code. Firefox and Safari, it could be that something needs to be be enabled or disabled not sure yet. I’ll keep searching! Thanks again.