freeCodeCamp Challenge Guide: Inherit Behaviors from a Supertype

Inherit Behaviors from a Supertype

Problem Explanation

To pass this challenge simply create the new duck and beagle objects using the Object.create() method seen in the following example.

let animal = Object.create(Animal.prototype);


Solution 1 (Click to Show/Hide)
function Animal() {}

Animal.prototype = {
  constructor: Animal,
  eat: function() {
    console.log("nom nom nom");

// Add your code below this line

let duck = Object.create(Animal.prototype); // Change this line
let beagle = Object.create(Animal.prototype); // Change this line; // Should print "nom nom nom"; // Should print "nom nom nom"