Skip to content

Instantly share code, notes, and snippets.

@pbrumblay
Created June 24, 2022 15:15
Show Gist options
  • Save pbrumblay/a6574c69fd888fe4aac1aa986ffb1477 to your computer and use it in GitHub Desktop.
Save pbrumblay/a6574c69fd888fe4aac1aa986ffb1477 to your computer and use it in GitHub Desktop.
Using Vietnamese numerology, is your number lucky?
const myArgs = process.argv.slice(2);
let computedNum = 99999;
let numString = myArgs[0];
while(computedNum > 9) {
let sum = 0;
for (var i = 0; i < numString.length; i++) {
sum += parseInt(numString.charAt(i));
}
computedNum = sum;
numString = computedNum + '';
}
switch(computedNum) {
case 0:
case 1:
case 2:
case 3:
console.log('Not lucky. Not unlucky.');
break;
case 4:
console.log('OMG you are screwed. Run away. Run far away.');
break;
case 5:
console.log('Not lucky. Not unlucky.');
break;
case 6:
console.log('I get a different answer every time I ask my wife if this is lucky.');
break;
case 7:
console.log('Not lucky. Not unlucky.');
break;
case 8:
console.log('This is a really lucky number.');
break;
case 9:
console.log('This is the luckiest most lucky super awesome number ever.');
break;
}
@pbrumblay
Copy link
Author

$ node vietnameseLucky.js 293921
This is a really lucky number.
$ node vietnameseLucky.js 607   
OMG you are screwed. Run away. Run far away.
$ node vietnameseLucky.js 202
OMG you are screwed. Run away. Run far away.
$ node vietnameseLucky.js 405
This is the luckiest most lucky super awesome number ever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment