vendredi 25 septembre 2015

How to access an object inside an Array Javascript

I have a bunch of objects in an Array.

  • How can I access the objects?
  • And how to add a key to every object?

Example

var gradesArr = [
    {
        'name' : 'Пешо',
        'score' : 91
    },
    {
        'name' : 'Лилия',
        'score' : 290
    },
    {
        'name' : 'Алекс',
        'score' : 343,
    },
    {
        'name' : 'Габриела',
        'score' : 400
    },
    {
        'name' : 'Жичка',
        'score' : 70
    }]

I want to add a key hasPassed to the objects, which have a score over 100.

But I can't mind of a way to do this.

Aucun commentaire:

Enregistrer un commentaire