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" }] }); ```
1 ответ
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)
}