Nashorn: Difference between revisions
Jump to navigation
Jump to search
(Created page with " sudo apt install openjdk-8-jdk update-alternatives --query jjs sudo update-alternatives --config jjs jjs -v ==NRIC By Age== {| | valign="top" colspan="2" | mkdir -p ~/Do...") |
|||
Line 62: | Line 62: | ||
| valign="top" colspan="2" | | | valign="top" colspan="2" | | ||
<source lang="bash"> | <source lang="bash"> | ||
jjs -v | |||
load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js'); | load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js'); | ||
</source> | </source> |
Revision as of 07:24, 24 January 2024
sudo apt install openjdk-8-jdk update-alternatives --query jjs sudo update-alternatives --config jjs jjs -v
NRIC By Age
mkdir -p ~/Documents/nashorn-playground cd ~/Documents/nashorn-playground | |
| |
cat <<'EOF' >> ~/Documents/nashorn-playground/printNricOf18YearsMan.js
function printNricOf18YearsMan(message) {
var AGE_18 = 18,
todayDate = moment(),
NRIC_FORMAT = 'YYMMDD-[01]-[0001]',
dobOf18YearsOld = todayDate.subtract(AGE_18, 'years'),
nricOf18YearsOld = dobOf18YearsOld.format(NRIC_FORMAT),
aDayEarly18Years = dobOf18YearsOld.subtract(1, 'days'),
nricOfDayEarly18 = aDayEarly18Years.format(NRIC_FORMAT);
message = 'NRIC of'
+ '\n18 Years old: ' + nricOf18YearsOld
+ '\n17 Years old: ' + nricOfDayEarly18;
print(message);
}
EOF
|
cat <<'EOF' >> ~/Documents/nashorn-playground/printNricOf56YearsMan.js
function printNricOf56YearsMan(message) {
var AGE_56 = 56,
todayDate = moment(),
NRIC_FORMAT = 'YYMMDD-[01]-[0001]',
dobOf56YearsOld = todayDate.subtract(AGE_56, 'years'),
nricOf56YearsOld = dobOf56YearsOld.format(NRIC_FORMAT),
aDayEarly56Years = dobOf56YearsOld.subtract(1, 'days'),
nricOfDayEarly56 = aDayEarly56Years.format(NRIC_FORMAT);
message = 'NRIC of'
+ '\n56 Years old: ' + nricOf56YearsOld
+ '\n55 Years old: ' + nricOfDayEarly56;
print(message);
}
EOF
|
| |
jjs -v
load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js');
| |
| |
load('./printNricOf18YearsMan.js');
printNricOf18YearsMan();
|
load('./printNricOf56YearsMan.js');
printNricOf56YearsMan();
|
References
|
||
| ||