aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-095/abigail/README.md1
-rw-r--r--challenge-095/abigail/node/ch-1.js20
-rw-r--r--challenge-095/abigail/t/ctest.ini3
3 files changed, 24 insertions, 0 deletions
diff --git a/challenge-095/abigail/README.md b/challenge-095/abigail/README.md
index aead395b0a..c0798385a0 100644
--- a/challenge-095/abigail/README.md
+++ b/challenge-095/abigail/README.md
@@ -20,6 +20,7 @@ Output: 0
~~~~
### Solutions
+* [Node](node/ch-1.js)
* [Perl](perl/ch-1.pl)
diff --git a/challenge-095/abigail/node/ch-1.js b/challenge-095/abigail/node/ch-1.js
new file mode 100644
index 0000000000..b753147ba9
--- /dev/null
+++ b/challenge-095/abigail/node/ch-1.js
@@ -0,0 +1,20 @@
+//
+// Make a pattern matching an unsigned decimal number.
+//
+var XRegExp = require ('xregexp');
+var pattern = XRegExp ('^\\p{Nd}+(?:\\.\\p{Nd}+)?$', 'u');
+
+ require ("fs")
+. readFileSync (0) // Read all.
+. toString () // Turn it into a string.
+. split ("\n") // Split on newlines.
+ // Remove trailing empty line.
+. filter ((_, i, a) => i != a . length - 1)
+ // Check wether the input is a) a palindrome,
+ // and 2) a decimal number.
+ //
+. map (_ => console . log (_ == _ . split ("")
+ . reverse ()
+ . join ("") &&
+ XRegExp . match (_, pattern) ? 1 : 0))
+;
diff --git a/challenge-095/abigail/t/ctest.ini b/challenge-095/abigail/t/ctest.ini
index 251a0f8e01..6e05838ac8 100644
--- a/challenge-095/abigail/t/ctest.ini
+++ b/challenge-095/abigail/t/ctest.ini
@@ -6,3 +6,6 @@
1-5 = Script run check
2-1 = Given example
2-2 = Test empty stack
+
+[1-5/javascript]
+skip = No script runs assertions available