Jelajahi Sumber

Update Stack.prototype.Push

Updated to allow for pushing of arrays. The explodes the array ensuring
the stack remains flat.
ApisNecros 1 tahun lalu
induk
melakukan
8bdd7821b7
1 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 6 1
      starfish.js

+ 6 - 1
starfish.js

@@ -733,7 +733,12 @@ class Stack {
      * @param {*} newValue 
      */
     Push(newValue) {
-        this.stack.push(newValue);
+        if(Array.isArray(newValue)) {
+            this.stack.push(...newValue);
+        }
+        else {
+            this.stack.push(newValue);
+        }
     }
     /**
      * Wrapper function for Array.prototype.pop