aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-05-03 19:15:30 +0200
committerAbigail <abigail@abigail.be>2021-05-03 19:16:34 +0200
commitfb6114ea6265a0a8242fb07246026fe0023329d6 (patch)
tree30b47c85a945eba53c4cdc343dc54128723443e4
parente2e3fac2bc03b46c8bf1400f842e6b4e4b7b70b1 (diff)
downloadperlweeklychallenge-club-fb6114ea6265a0a8242fb07246026fe0023329d6.tar.gz
perlweeklychallenge-club-fb6114ea6265a0a8242fb07246026fe0023329d6.tar.bz2
perlweeklychallenge-club-fb6114ea6265a0a8242fb07246026fe0023329d6.zip
Node.js solution for week 111, part 2
-rw-r--r--challenge-111/abigail/README.md1
-rw-r--r--challenge-111/abigail/node/ch-2.js23
2 files changed, 24 insertions, 0 deletions
diff --git a/challenge-111/abigail/README.md b/challenge-111/abigail/README.md
index 88811306fc..87191419b0 100644
--- a/challenge-111/abigail/README.md
+++ b/challenge-111/abigail/README.md
@@ -53,6 +53,7 @@ to standard output. In case of ties, we print the first one found.
* [GNU AWK](awk/ch-2.gawk)
* [C](c/ch-2.c)
* [Lua](lua/ch-2.lua)
+* [Node.js](node/ch-2.js)
* [Perl](perl/ch-2.pl)
### Blog
diff --git a/challenge-111/abigail/node/ch-2.js b/challenge-111/abigail/node/ch-2.js
new file mode 100644
index 0000000000..3d7b301b5d
--- /dev/null
+++ b/challenge-111/abigail/node/ch-2.js
@@ -0,0 +1,23 @@
+#!/usr/local/bin/node
+
+//
+// See ../README.md
+//
+
+//
+// Run as: node ch-2.js < input-file
+//
+
+let longest = ""
+
+require ('readline')
+. createInterface ({input: process . stdin})
+. on ('line', _ => {
+ if (_ . match (/^a*b*c*d*e*f*g*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$/i) &&
+ _ . length > longest . length) {
+ longest = _
+ }
+})
+. on ('close', _ => {
+ console . log (longest)
+})