code from chapter 5 in javascript

This commit is contained in:
Kevin Nguyen
2016-06-17 10:03:11 -07:00
parent bad0a2ac3d
commit 96c766f9d9
2 changed files with 26 additions and 0 deletions

View 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!