Code Making

To protect information, codes are needed. Here is a JavaScript code instructions to create some easy code:

Checks whether if a person wants to encode or decode.

Accepts a string of 27 characters, checks if it is a permutation of "abcdefghijklmnopqrstuvwxyz " (and the space, of course)


It goes through the message character by character.
For each character, it searches for that character and notes the position (n) in the string. It finds the nth character in the string "abcdefghijklmnopqrstuvwxyz " and notes it down, constructing a separate string.


Also character by character.
Finds the character in the string "abcdefghijklmnopqrstuvwxyz ", noting down the position (n) and finding the nth character in the user-input string. Notes that character down and constructs a separate string.

Outputs string.

var checker=/[a-z]{26}/gi;
function simplecode() {
var compareto = "abcdefghijklmopqrstuvwxyz ";
while (check!=encoder) {
var encoder = prompt("Type the key.");
var decode = confirm("Decode? (Cancel encodes)");
if (answer) {
// Decode
var todecode = prompt("What to decode?");
answer = "";
for (chardec=0; chardec<todecode.length() chardec++) {
addon = encoder.charAt(;
answer += addon;
else {
// Encode
var toencode = prompt("What to encode?");
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License