const films = [ { name: "JAWS", director: "Spielberg", boxOffice: 127 } ,{ name: "SPychose", director: "Hitchcock", boxOffice: 23 } ,{ name: "ET", director: "Spielberg", boxOffice: 244 } ] //input director = "Saisir nom du director"; let nbEnt = 0; for (let index = 0; index < films.length; index++) { if (films[index].director == "Spielberg"/*director*/){ nbEnt += films[index].boxOffice; console.log(films[index].name); } } console.log(`nombre entré ${nbEnt}`);
Commentaires
Enregistrer un commentaire