Caesar 25 variants new

by aninaslyan

JavaScript

function chipher(coded) {
	let alphabet = "abcdefghijklmnopqrstuvwxyz";
  let str = "";
  
  for (let i=0; i<coded.length; i++) {
  	let index = alphabet.indexOf(coded[i]);
    console.log(index, "index");
    for(let j=index;;j--) {
    	str = str + alphabet[j];
    	console.log(str)
    }
    /* let newIndex = index + num;
    
    if(newIndex > 25) {
      newIndex -= 26;
    }
    if(str[i] === str[i].toUpperCase()) {
      coded += alphabet[newIndex].toUpperCase();
    } else {
      coded += alphabet[newIndex];
    }
    
    if(str[i] === " ") {
      coded = coded + alphabet[newIndex] + " ";
    } */
  }
}

//text = prompt("Input text");
chipher("dql");