Files
grokking_algorithms/05_hash_tables/ES6/02_check_voter.js
2019-07-23 08:37:29 +04:00

19 lines
352 B
JavaScript

const voted = {};
/**
* Vote check
* @param {string} name Voter name
*/
const checkVoter = name => {
if (voted[name]) {
console.log("kick them out!");
} else {
voted[name] = true;
console.log("let them vote!");
}
};
checkVoter("tom"); // let them vote!
checkVoter("mike"); // let them vote!
checkVoter("mike"); // kick them out!