code from chapter 5 in javascript
This commit is contained in:
16
05_hash_tables/javascript/02_check_voter.js
Normal file
16
05_hash_tables/javascript/02_check_voter.js
Normal file
@@ -0,0 +1,16 @@
|
||||
'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!
|
||||
Reference in New Issue
Block a user