瀏覽代碼

Add function to get the decimal value of a char

ApisNecros 2 年之前
父節點
當前提交
f27a18c0b4
共有 1 個文件被更改,包括 13 次插入0 次删除
  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);
 }