Might be a bit overkill for your purposes, but you asks for counts. This will return an object containing the count of each value in found in the original object. You might want to do more type checking. For example, ensure the value of the object is something meaningful or of an expected value. Its a bit meaningless to count {'DoctorA': ['N','S'], 'DoctorB': ['N','S']};
using the function below.
/**
* 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",
DoctorAM: "N",
DoctorAN: "Y",
DoctorAO: "Y",
DoctorAP: "Y",
DoctorA: "Y",
DoctorAQ: "Y",
DoctorAR: "Y",
DoctorAS: "Y",
DoctorAT: "N",
DoctorAU: "Y",
DoctorAV: "Y",
DoctorAW: "Y",
DoctorAX: "Y",
DoctorB: "Y",
DoctorAY: "Y",
DoctorAZ: "Y",
DoctorBA: "Y",
DoctorBB: "Y",
DoctorBC: "Y",
DoctorC: "Y",
DoctorBD: "Y",
DoctorBE: "Y",
DoctorBF: "Y"
};
var value_counts = value_count(input),
key;
console.log('counts:');
for (key in value_counts) {
console.log(' property ' + key + ' appeared ' + value_counts[key] + ' times');
}