JSFiddle - React, Tailwind, and code Playground
JavaScript
/**
* count the values from a set of key value pairs and count the occurrences of each value
* @param {object} input - an object containing key value pairs
* @throws {error} TypeError - if <tt>input</tt> is not an object
* @return {object} counts - an object keying the number of times each value occurs
*/
var value_count = function (input) {
if (Object.prototype.toString.call(input) === '[object Object]') {
var counts, key, val;
console.log(input);
counts = {};
for (key in input) {
val = input[key];
if (input.hasOwnProperty(key)) {
if (counts.hasOwnProperty(val)) {
counts[val] += 1;
} else {
counts[val] = 1;
}
}
}
return counts;
} else {
throw new TypeError('expected input to be an Object');
}
};
//input
var input = {
DoctorD: "N",
DoctorE: "N",
DoctorF: "N",
DoctorG: "N",
DoctorH: "N",
DoctorI: "N",
DoctorJ: "N",
DoctorK: "N",
DoctorL: "N",
DoctorM: "N",
DoctorN: "N",
DoctorO: "N",
DoctorP: "N",
DoctorQ: "N",
DoctorR: "N",
DoctorS: "N",
DoctorT: "N",
DoctorU: "N",
DoctorV: "Y",
DoctorW: "N",
DoctorX: "N",
DoctorY: "N",
DoctorZ: "N",
DoctorAA: "N",
DoctorAB: "N",
DoctorAC: "N",
DoctorAE: "N",
DoctorAF: "N",
DoctorAG: "N",
DoctorAH: "N",
DoctorAI: "N",
DoctorAJ: "N",
DoctorAK: "N",
DoctorAL: "N",
...