aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-096/abigail/node/ch-1.js19
1 files changed, 7 insertions, 12 deletions
diff --git a/challenge-096/abigail/node/ch-1.js b/challenge-096/abigail/node/ch-1.js
index 15aa190086..994c1e1971 100755
--- a/challenge-096/abigail/node/ch-1.js
+++ b/challenge-096/abigail/node/ch-1.js
@@ -8,15 +8,10 @@
// Run as: node ch-1.js < input-file
//
- require ("fs")
-. readFileSync (0) // Read all.
-. toString () // Turn it into a string.
-. split ("\n") // Split on newlines.
-. filter (_ => _ . length) // Filter out empty lines.
-. map (_ => console . log (_ . trim () // Remove leading
- // and trailing
- // whitespace.
- . split (/\s+/) // split ...
- . reverse () // reverse ...
- . join (" "))) // and recombine.
-;
+require ('readline')
+. createInterface ({input: process . stdin})
+. on ('line', _ =>
+ console . log (_ . trim () // Remove leading/trailing spaces
+ . split (/\s+/) // Split on white space
+ . reverse () // Reverse the words
+ . join (" "))) // And join them again.