This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Like my previous post said, I'm still very new to JS. I'm currently looking at a practice problem where I'm given an array of objects labeled as classroom. Within it, there are several key sections and the one I'm currently trying to grab is the "assignments" section.
I started out like this
let assignmentsGrab = classroom.assignments
console.log(assignmentsGrab)
This ends up working and shows me all of the assignment entries. Now I'm having trouble accessing a specific one based on its ID and grabbing its name and point value. This is the code itself I'm trying to access. For example, if I want to grab the name and points of id:103, how would I go about it. I'm assuming I'm going to need a for loop but I'm not sure how the syntax of it would go for this.
assignments: [
{
id: 101,
name: "Intro",
pointsPossible: 5,
},
{
id: 102,
name: "Lesson 1",
pointsPossible: 10,
},
{
id: 103,
name: "Lesson 2",
pointsPossible: 10,
},
{
id: 104,
name: "Final",
pointsPossible: 30,
}
]
^These are all inside the classroom object and assignments is the next level down.
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnjavasc...