"missed_votes_pct" = [4.61, 0.53, 0.18, 0.89, 0.53, 2.3, 4.96,
0.71, 0.35, 4.26, 0.35, 1.06, 0.89, 1.06,
0.18, 0.89, 9.54, 0, 3.9, 4.26, 0.35, 1.77,
0.35, 0.53, 5.67, 0.35, 1.42, 13.65, 2.66,
0.18, 0.18, 6.38, 0.71, 8.51, 4, 0.35, 0.35,
5.14, 0, 0.35, 0.53, 0.35, 4.61, 3.01, 4.43,
2.13, 1.24, 1.7, 2.13, 10.99, 0.53, 2.09,
0.53, 0.35, 0, 0.53, 0, 0.35, 3.01, 1.77,
0.89, 0.53, 45.56, 2.48, 0, 14.89, 1.77,
4.43, 3.19, 0.35, 2.84, 6.21, 3.55, 1.24,
0.89, 0.71, 0, 0.89, 1.24, 1.6, 6.21, 2.48,
1.06, 2.13, 0.18, 0.89, 65, 3.19, 0.89, 0,
0.89, 3.4, 3.55, 1.06, 0, 3.37, 4.96, 1.06, 0.71,
1.42]
function getTenPerOfMissed(array) {
var temp = [];
var len = array.length * 0.1;
for (var i = 0; i < array.length; i++) {
// console.log(array[i].missed_votes_pct);
if (i < len) {
temp.push(array[i]);
} else if (array[i].missed_votes_pct == array[i - 1].missed_votes_pct) { //find the 10% of the lowest values and keep also values that repeated
temp.push(array[i]);
} else {
break;
}
}
console.log(temp);
}
function bottomTenPercent() {
members.sort(function(a, b) {
return a.missed_votes_pct - b.missed_votes_pct; //sort our array from lower to higher and call getTenPerOfMissed(members)
//to keep the 10% of the lowest values
});
// console.log("Lowest" , members)
getTenPerOfMissed(members)
}
function TopTenPercent() {
members.sort(function(a, b) {
return b.missed_votes_pct - a.missed_votes_pct;
});
getTenPerOfMissed(members);
}
bottomTenPercent();
TopTenPercent();