0

I am trying to create a new key-value or associative array "gradepoints" using two old arrays "grades" and "array". I tried with and without curly braces in the loop.

var gradepoints = [];
for(var i=0; i<array.length; i++) {
    gradepoints[i] = {array[i] : grades[array[i]] };
}
user2714639
  • 57
  • 1
  • 7

1 Answers1

1
var gradepoints = {};
for(var i=0; i<array.length; i++) {
    gradepoints[array[i]] = grades[array[i]];
}
SajithNair
  • 3,867
  • 1
  • 17
  • 23