JSFiddle - React, Tailwind, and code Playground
by Emily Humphrey
JavaScript
var formattedPrecincts = [];
var engagePrecincts = [];
var precincts = [
"0501 PCT 501 1344 744 1 35 72.54",
"0502 PCT 502 1937 1450 0 47 69.11",
"0503 PCT 503 566 296 0 9 74.19",
"0504 PCT 504 826 686 0 24 63.66",
"0506 PCT 506 1102 846 0 43 69.66",
"0508 PCT 508 957 648 0 30 67.41",
"0509 PCT 509 524 244 0 14 64.31 ",
"0510 PCT 510 1964 1177 0 62 73.38",
"0511 PCT 511 451 181 0 8 64.65",
"0512 PCT 512 1665 1298 0 60 66.82",
"0515 PCT 515 876 977 1 38 57.84",
"0516 PCT 516 1099 705 1 34 74.51",
"0517 PCT 517 833 685 0 28 61.08",
"0519 PCT 519 482 486 0 23 61.86",
"0521 PCT 521 1655 1190 0 49 70.24",
"0522 PCT 522 1340 1094 0 47 62.38",
"0523 PCT 523 720 661 0 20 50.98",
"0526 PCT 526 475 548 1 26 50.41",
"0527 PCT 527 533 540 0 19 54.85",
"0528 PCT 528 443 537 0 26 50.20",
"0529 PCT 529 524 540 0 16 53.68",
"0530 PCT 530 489 638 0 25 47.58",
"0532 PCT 532 1379 701 0 28 81.26",
"0602 PCT 602 1664 1392 0 46 61.58",
"0603 PCT 603 477 1654 0 32 55.93",
"0607 PCT 607 1454 1236 0 58 60.50",
"0614 PCT 614 306 1593 0 44 46.06",
"0619 PCT 619 175 875 0 24 45.45",
"0620 PCT 620 27 970 0 32 44.70",
"0621 PCT 621 113 832 0 22 45.92",
"0622 PCT 622 138 203 0 6 34.39",
"0623 PCT 623 679 649 1 30 49.03",
"0625 PCT 625 674 458 0 17 65.69",
"0626 PCT 626 384 464 0 24 52.28",
"0628 PCT 628 338 1616 0 42 46.27",
"0633 PCT 633 736 1190 0 36 43.77",
"0638 PCT 638 835 654 0 31 63.39",
"0641 PCT 641 1482 1309 0 50 57.80",
"0701 PCT 701 1505 1253 0 52 60.68",
"0703 PCT 703 1156 1099 0 38 56.62",
"0705 PCT 705 561 389 0 15 65.56",
"0706 PCT 706 2049 1120 0 52 69.52 "
];
precincts.forEach((i)=>{
i = i.split(" ");
var obj = {
precinctCode: i[2],
republicanVoters: i[3],
democratVoters: i[4],
underVoters: i[5],
overVoters: i[6],
turnout: i[7]
};
formattedPrecincts.push(obj);
});
formattedPrecincts.forEach((i)=>{
if( ((i.democratVoters < i.republicanVoters)) ){
engagePrecincts.push(i);
}
})
console.log(formattedPrecincts);
console.log(engagePrecincts);