Help! hello friends i tried this code and i need your help

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function Dog(name) {
this.name = name;
}

Dog.prototype.numLegs = 4;

let beagle = new Dog("Snoopy");

let ownProps = [];
let prototypeProps = [];

// Only change code below this line

for (let property in Dog) {
if(beagle.hasOwnProperty(property)) {
  ownProps.push(property);
} else {
  prototypeProps.push(property);
}
}
console.log("ownProps" , ownProps);
console.log("prototypeProps" , prototypeProps);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36

Challenge: Iterate Over All Properties

Link to the challenge:

Hello!

Double-check your for loop statements, you aren’t supposed to be parsing the Dog constructor.

Hope this helps!

yes, I understandood, thank you.

sol:
function Dog(name) {
this.name = name;
}

Dog.prototype.numLegs = 4;

let beagle = new Dog(“Snoopy”);

let ownProps = ;
let prototypeProps = ;

// Only change code below this line

for (let property in beagle {
if(beagle.hasOwnProperty(property)) {
ownProps.push(property);
} else {
prototypeProps.push(property);
}
}
console.log(“ownProps” , ownProps);
console.log(“prototypeProps” , prototypeProps);

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.