Soy nuevo en JavaScript y trato de escribir un decodificador para el cifrado César. Pero mi código no funciona, no se muestran errores y no se detiene.
let word = "привет"; let shift = 3; let result = ""; for (let i = 0; i < word.legth; i++){ if ('А'.charCodeAt(0) <= word[i].charCodeAt(0) <= 'Я'.charCodeAt(0)) { let char = ((word[i].charCodeAt(0) + shift - 'А'.charCodeAt(0)) % 32) + 'А'.charCodeAt(0) result = result + String.fromCharCode(char); } else if ('а'.charCodeAt(0) <= word[i].charCodeAt(0) <= 'я'.charCodeAt(0)) { let char = ((word[i].charCodeAt(0) + shift - 'а'.charCodeAt(0)) % 32) + 'а'.charCodeAt(0) result = result + String.fromCharCode(char); } else { result = result + word[i]; } } console.log(result)Cambiar palabra.longitud a palabra.longitud
let word = 'привет'; let shift = 3; let result = ''; for (let i = 0; i < word.length; i++) { if ('А'.charCodeAt(0) <= word[i].charCodeAt(0) <= 'Я'.charCodeAt(0)) { let char = ((word[i].charCodeAt(0) + shift - 'А'.charCodeAt(0)) % 32) + 'А'.charCodeAt(0); result = result + String.fromCharCode(char); } else if ( 'а'.charCodeAt(0) <= word[i].charCodeAt(0) <= 'я'.charCodeAt(0) ) { let char = ((word[i].charCodeAt(0) + shift - 'а'.charCodeAt(0)) % 32) + 'а'.charCodeAt(0); result = result + String.fromCharCode(char); } else { result = result + word[i]; } } console.log(result);