samedi 17 juillet 2021

Filtering: Filtering Generate an array of Presidents that served more than 4 years and that were not Democrats

The Exercise and Array

function mapPresidents(person) {

var freshList = {
  id: person.id,
  number: person.president,
  firstName: person.nm[0],
  party: person.pp,
  yearsInOffice: officeYears,
};

let years = person.tm.split("-");

let officeYears= 0

if(years.length > 1){
  officeYears = toNumber(years[1]) - toNumber(years[0])
  console.log(officeYears);
}

return freshList;

}

var newPresidents = presidents.map(mapPresidents);

function filterPresidents(person) { let result = false;

if() {

}

return result;

}

I am having trouble with the logic that should be fed into my if statement to complete the filter.

"Generate an array of Presidents that served more than 4 years and that were not Democrats"

Aucun commentaire:

Enregistrer un commentaire