JSFiddle - React, Tailwind, and code Playground
by Emily Humphrey
JavaScript
var formattedPrecincts = [];
var engagePrecincts = [];
var precincts = [
"614 476 1898 60.06",
"628 404 1887 59.05",
"603 502 1735 68.04",
"633 1009 1528 61.27",
"502 2195 1441 78.04",
"641 1819 1440 72.59",
"602 1749 1411 73.41",
"620 27 1390 61.52",
"512 1884 1348 80.74",
"607 1667 1302 71.31",
"701 1788 1269 71.4",
"703 1442 1213 71.06",
"521 1855 1171 78.29",
"510 2170 1160 84.01",
"522 1640 1092 75.05",
"706 2175 1086 77.87",
"619 212 1082 59.58",
"621 132 1001 53.96",
"515 1102 976 71.22",
"506 1269 872 80.44",
"516 1186 734 82.67",
"623 795 720 60.63",
"504 980 717 75.57",
"530 710 694 62.56",
"501 1419 691 79.97",
"517 1000 676 73.42",
"523 962 667 64.48",
"638 967 663 73.78",
"532 1406 650 88.23",
"508 1071 592 78.08",
"526 603 575 63.63",
"528 573 569 62.59",
"527 655 557 67.32",
"529 647 522 65.74",
"626 447 519 62.37",
"519 535 514 72.12",
"625 761 451 74.63",
"705 708 368 78.16",
"503 607 302 84.58",
"509 580 245 72.85",
"622 216 241 52.58",
"511 532 167 76.24",
];
precincts.forEach((i)=>{
i = i.split(" ");
var obj = {
precinctCode: i[0],
republicanVoters: parseFloat(i[1]),
democratVoters: parseFloat(i[2]),
turnout: parseFloat(i[3])
};
formattedPrecincts.push(obj);
});
formattedPrecincts.forEach((i)=>{
if(i.democratVoters > i.republicanVoters){
engagePrecincts.push(i);
}
});
console.log(engagePrecincts);