Nommiin icon

nommlang - js

Nommiin | PRO | 02/25/17 04:53:02 AM UTC | 0 ⭐ | 274 👁️ | Never ⏰ | []
JavaScript |

1.03 KB

|

None

|

0 👍

/

0 👎

/*
"N" starts a new line, "O" begins the message to print, and every "m" you put determines the letter, continued with a space to indicate a new letter
Hello in nommlang would be
 
n o mmmmmmmm mmmmm mmmmmmmmmmmm mmmmmmmmmmmm mmmmmmmmmmmmmmm in
*/
 
// modified to run in a single function call, instead of relying on the page
function run(input) {
    var stringPrint = "", canPrint = false, charIndex = 0;
    domOutput.value = "";
    
    for(var i = 0; i < input.length; i++) {
        switch (input[i].toLowerCase()) {
            case "n": {
                stringPrint  += "\n";
            break;}
 
            case "o": {
                canPrint = true;
            break;}
 
            case "m": {
                charIndex++;
            break;}
 
            case " ": {
                if (canPrint == true) {
                    stringPrint  += String.fromCharCode(64 + charIndex);
                    charIndex = 0;
                }
            break;}
        }
    }
    console.log(stringPrint);
}

Comments