Files
grokking_algorithms/05_hash_tables/javascript/02_check_voter.js
2016-06-17 19:14:45 -07:00

17 lines
312 B
JavaScript

'use strict';
const voted = {};
function check_voter(name) {
if (voted[name]) {
console.log('kick them out!');
} else {
voted[name] = true;
console.log('let them vote!');
}
}
check_voter("tom"); // let them vote!
check_voter("mike"); // let them vote!
check_voter("mike"); // kick them out!