aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-095/nunovieira220/js/ch-1.js9
-rw-r--r--challenge-095/nunovieira220/js/ch-2.js37
2 files changed, 46 insertions, 0 deletions
diff --git a/challenge-095/nunovieira220/js/ch-1.js b/challenge-095/nunovieira220/js/ch-1.js
new file mode 100644
index 0000000000..9b1f3141e5
--- /dev/null
+++ b/challenge-095/nunovieira220/js/ch-1.js
@@ -0,0 +1,9 @@
+// Input
+const num = 1221;
+
+// Palindrome Number
+const numStr = `${num}`;
+const res = numStr === numStr.split('').reverse().join('') ? 1 : 0;
+
+// Output
+console.log(res); \ No newline at end of file
diff --git a/challenge-095/nunovieira220/js/ch-2.js b/challenge-095/nunovieira220/js/ch-2.js
new file mode 100644
index 0000000000..cb08c08503
--- /dev/null
+++ b/challenge-095/nunovieira220/js/ch-2.js
@@ -0,0 +1,37 @@
+// Stack class
+class Stack {
+ constructor() {
+ this.stack = [];
+ }
+
+ push(elem) {
+ this.stack.push(elem);
+ }
+
+ pop() {
+ return this.stack.pop();
+ }
+
+ top() {
+ return this.stack[this.stack.length - 1];
+ }
+
+ min() {
+ return Math.min(...this.stack);
+ }
+
+ toString() {
+ console.log(this.stack);
+ }
+}
+
+// Input
+const stack = new Stack();
+stack.push(2);
+stack.push(-1);
+stack.push(0);
+stack.pop(); // removes 0
+console.log(stack.top()); // prints -1
+stack.push(0);
+console.log(stack.min()); // prints -1
+stack.toString(); \ No newline at end of file