0

There is a code that I found online which I used as reference for my exercise but I don't understand one point. On line 4, he used input[i][field] to access the value of the key. I thought it should be input[i].field according to the rules I learned.

    var output = [];
    for (var i=0; i < input.length ; ++i)
        output.push(input[i][field]);
    return output;
}

var result = getFields(objArray, "foo"); // returns [ 1, 3, 5 ]```
Thi Nguyen
  • 49
  • 2
  • 6

0 Answers0