UNPKG

626 BPlain TextView Raw
1#!/usr/bin/env node
2
3/*
4 * intermediate
5 *
6 */
7
8
9var cui = require("../lib/cui");
10
11
12cui.push({
13 title: "Determine which day of the week you were born on:",
14 type: "fields",
15 data: [
16 "Month [MM]: ",
17 "Day [DD]: ",
18 "Year [YYYY]: "
19 ],
20 action: function (cb) {
21 var parts = cui.results.slice(-3);
22 var str = parts[0] + "/" + parts[1] + "/" + parts[2];
23 var birthday = new Date(str);
24 if (birthday === "Invalid Date") {
25 console.log(str + " is not a valid date.");
26 } else {
27 console.log("You were born on a " + birthday.toLocaleDateString().split(",")[0] + ".");
28 }
29 cb();
30 }
31});