Answers for "how to create an encoder and decoder in javaScript"

1

how to create an encoder and decoder in javaScript

var x = prompt("Select your desired option \n 1) Encode \n 2) Decode \n ", +x);
var choice = parseInt(x);
var str;
switch (choice) {
    case 1:
        str = prompt("Enter words to be encoded: \n " + str);
        var encodedStr = btoa(str);
        alert(encodedStr);
        break;
    case 2:
        str = prompt("Enter words to be decoded: \n " + str);
        var decodedStr = atob(str);
        alert(decodedStr);
        break;

}

str = undefined;
//Taizya was here
Posted by: Guest on October-23-2021

Code answers related to "how to create an encoder and decoder in javaScript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language