I'm new & doing this exercise on exercism.io, I'm trying to push the value pair into the object, here my code so far:
class School{
constructor(){
this.rosterList = {};
}
roster(){
return this.rosterList;
}
add(name,grade){
let nameArry = [];
this.rosterList.grade = nameArry.push(name);
}
}
let a = new School;
a.add('Aimee', 2)
console.log(a.roster());
which result in
{ grade: 1 }
the result I tried to get
{ 2: [ 'Aimee' ] }
My questions are why the array become 1? How to push the name into a array like it should ? And how to push the "2" inside, not the "grade" , thank you