JVFET
January 19, 2024, 6:09pm
1
Tell us what’s happening:
I’ve been stuck on this problem for hours. It’s asking to use the deconstruction syntax to access the ‘coachName’ value which is already nested inside of the ‘headCoach’ object. I don’t think the course has gone over on how to access a value inside of an object. The code I provided is from research I did on google and it still doesn’t work, what am I missing? I appreciate the help.
Your code so far
const { headCoach: { coachName } } = myFavoriteFootballTeam;
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Challenge Information:
Learn Modern JavaScript Methods By Building Football Team Cards - Step 20
Hey @JVFET and welcome to the FCC community!
When destructuring, the syntax is like this:
const { propertyName } = someObjectContainingThisProperty;
If I have an object like this:
const aRandomObject = {
personName: 'Bob Bobbertson'
};
I can use the destructuring syntax to access it.
const { personName } = aRandomObject;
console.log(`Hello, ${personName}, it is nice to meet you!`);
What that did was pull the property out of the object and into its own variable.
All you need to do is use that same syntax to pull the property coachName
out of the object myFavoriteFootballTeam.headCoach
.
JVFET
January 19, 2024, 6:23pm
3
Thank you Marcus that helped.
Zan1
January 28, 2024, 11:51am
4
const { myFavoriteFootballTeam, headCoach} = coachName;
what am i doing wrong?
const car = {
type: “sport”,
spec: {
yearBuilt: 2012,
manufacturer: “BMW”,
}
};
const { manufacturer } = car.spec;
system
Closed
July 30, 2024, 7:56am
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.