JavaScript Algorithms and Data Structures Basic JavaScript

Hi,

Kindly please assist, been stuck on this question i am failing to crack it. below is the description of the question.

Make an object that represents a dog called myDog which contains the properties name (a string), legs , tails and friends .

You can set these object properties to whatever values you want, as long as name is a string, legs and tails are numbers, and friends is an array.

  **Your code so far**

const myDog = {
// Only change code below this line
var myDog = {
"name": "Alpha",
"legs": 4,
"tails": 1,
"friends": ["everything"]
}

// Only change code above this line
};
  **Your browser information:**

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

Challenge: Build JavaScript Objects

Link to the challenge:

you redeclared the const myDog to Var and you don’t need to declare it again since const are immutable. The value of your objects inside your var can be the whole value of your const myDog.

const myDog = {
// Only change code below this line
var myDog = {

There is no need to redeclare myDog here because it has already been declared with the const keyword. So var myDog ={} need to be removed. I would rewrite this code as:

const myDog = {
// Only change code below this line

“name”: “Alpha”,
“legs”: 4,
“tails”: 1,
“friends”: [“everything”]

// Only change code above this line
};

Got it, Thank you for clarity i realize where my mistake was.

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Okay good to know. I had not thought of it that way! Thanks!

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