lundi 22 août 2016

JavaScript filter array function

I've made a list of ships that it represented like so:

var fleet = 
    ["RMS MARY", 2000, 15],
    ["TITANIC 2", 10000, 13],
    ["Boaty McBoatface", 2000, 18],
    ["Jutlandia", 1945, 10], 
    ["Hjejlen", 250, 8] 
];

I want to write a function that will filter the ships by a given capacity. Example:

filterByCapacity(fleet,5000)

This should only return the ship Titanic 2 since it is the only ship with a capacity higher than 5000. Any ideas on how to write such a function?

Aucun commentaire:

Enregistrer un commentaire