aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authore. alvarez <55966724+ealvar3z@users.noreply.github.com>2023-03-11 17:33:37 -0800
committere. alvarez <55966724+ealvar3z@users.noreply.github.com>2023-03-11 17:33:37 -0800
commit1df85bcd9cbc24c3685d70f176d143a588a581ea (patch)
tree9b12b3deca565302e356595f4cbd6f9f1422b850
parent1f9e919800ebc28992c10467f2e9a2d1afe90169 (diff)
downloadperlweeklychallenge-club-1df85bcd9cbc24c3685d70f176d143a588a581ea.tar.gz
perlweeklychallenge-club-1df85bcd9cbc24c3685d70f176d143a588a581ea.tar.bz2
perlweeklychallenge-club-1df85bcd9cbc24c3685d70f176d143a588a581ea.zip
week 207 solution in JavaScript
-rw-r--r--challenge-207/ealvar3z/blog.txt1
-rw-r--r--challenge-207/ealvar3z/js/ch-1.js31
-rw-r--r--challenge-207/ealvar3z/rust/.gitignore3
3 files changed, 32 insertions, 3 deletions
diff --git a/challenge-207/ealvar3z/blog.txt b/challenge-207/ealvar3z/blog.txt
new file mode 100644
index 0000000000..4e03b8b035
--- /dev/null
+++ b/challenge-207/ealvar3z/blog.txt
@@ -0,0 +1 @@
+https://eax.bearblog.dev/king-of-strings/
diff --git a/challenge-207/ealvar3z/js/ch-1.js b/challenge-207/ealvar3z/js/ch-1.js
new file mode 100644
index 0000000000..936504111f
--- /dev/null
+++ b/challenge-207/ealvar3z/js/ch-1.js
@@ -0,0 +1,31 @@
+#!/usr/bin/node
+
+const assert = require("assert");
+
+// Tests
+
+const test_one = ["Hello", "Alaska", "Dad", "Peace"];
+const test_two = ["OMG", "Bye"];
+
+const _1 = test_one.filter(task_one);
+const _2 = test_two.filter(task_one);
+
+console.log(_1);
+console.log(_2);
+
+assert.deepStrictEqual(_1, ["Alaska", "Dad"]);
+assert.deepStrictEqual(_2, []);
+
+// Implementation
+
+const q = /[qwertyuiop]+/i;
+const a = /[asdfghjkl]+/i;
+const z = /[zxcvbnm]+/i;
+
+function task_one(w) {
+ const compile = `^(${q.source}|${a.source}|${z.source})$`;
+ const re = new RegExp(compile, "i");
+ return re.test(w);
+}
+
+
diff --git a/challenge-207/ealvar3z/rust/.gitignore b/challenge-207/ealvar3z/rust/.gitignore
deleted file mode 100644
index 9a30948bdd..0000000000
--- a/challenge-207/ealvar3z/rust/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/target
-Cargo.toml
-Cargo.lock