Przeglądaj źródła

Add function to get the decimal value of a char

ApisNecros 2 lat temu
rodzic
commit
f27a18c0b4
1 zmienionych plików z 13 dodań i 0 usunięć
  1. 13 0
      starfish.js

+ 13 - 0
starfish.js

@@ -294,4 +294,17 @@ class Stack {
     PushLength() {
         this.stack.push(this.stack.length);
     }
+}
+
+/**
+ * Get the char code of any character
+ *
+ * Can actually take any length of a value, but only returns the
+ * char code of the first character.
+ *
+ * @param {*} value Any character
+ * @returns {int} The value's char code
+ */
+function dec(value) {
+    return value.toString().charCodeAt(0);
 }