<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Object basics: Task 4</title>
<link rel="stylesheet" href="../styles.css" />
</head>
<body>
<section class="preview">
</section>
</body>
</html>
p {
color: purple;
margin: 0.5em 0;
}
* {
box-sizing: border-box;
}
function Cat(name, breed, color) {
this.name = name;
this.breed = breed;
this.color = color;
this.greeting = function() {
console.log(`Hello, said ${this.name} the ${this.breed}.`);
}
}
const cat = new Cat('Bertie', 'Cymric', 'white');
const cat2 = new Cat('Freddy', 'Siberian', 'grey');
cat.greeting();
cat2.greeting();
/*Original
function Cat(name, breed, color) {
this.catName = name;
this.catBreed = breed;
this.catColor = color;
this.catGreeting = function() {
console.log(`Hello, said ${this.catName} the ${this.catBreed}.`);
};
}
const cat = new Cat('Bertie', 'Cymric', 'white');
const cat2 = new Cat('Freddy', 'Siberian', 'gray');
cat.catGreeting();
cat2.catGreeting();
*/
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.