I just started with OOP on Javascript. I am new to programming world. Could you please help me on the following code? My text editor shows syntax error on ‘else’ block.
function Dog(name, breed, weight) {
this.name = name;
this.breed = breed;
this.weight = weight;
this.bark = function () {
if (this.weight > 25) alert(this.name + " says Woof")
} else {
alert(this.name + " says Poof");
}
}
var fido = new Dog("Fido", "Mixed", 38);
fido.bark();
Try this