How to acssess a nested Object inside a Map() Object ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to acssess a nested Object inside a Map() Object ?

I want to create a dropDown menu <select> and fill it with the keys of the students, and when the user clicks on an option (key/student name)=> I want the grades of that student to be printed on the page ``` var student = new Map(); student.set("Marina", { Grades: [ { Coursename: "JavaScript", Grade: "Excellent" }, { Coursename: "Jquery", Grade: "Good" }, { Coursename: "CSS", Grade: "V.Good" }] }); student.set("Mariam", { Grades: [ { Coursename: "JavaScript", Grade: "Excellent" }, { Coursename: "Jquery", Grade: "Good" }, { Coursename: "CSS", Grade: "V.Good" }] }); ```

12th Dec 2021, 4:42 PM
Marina Khamis
Marina Khamis  - avatar
1 Answer
0
Marina Khamis Try this way: var gd = student.get('Mariam'); var grades = gd.Grades; for (var i of grades) { console.log(i.Coursename + ' - ' + i.Grade) }
12th Dec 2021, 6:43 PM
A͢J
A͢J - avatar