Cifrado Cesar - Andrea Chumioque#68
Cifrado Cesar - Andrea Chumioque#68AndreaChumioque wants to merge 3 commits intoLaboratoria-learning:masterfrom
Conversation
|
@developerVilchez |
js/app.js
Outdated
| // Encontramos el código de cada caracter con el método charCodeAt | ||
| origCode = msg.charCodeAt(i); | ||
| // Si el caracter es mayuscula se encuentra entre los codigos 65 y 90 | ||
| if (origCode >= 65 && origCode <= 90) { |
There was a problem hiding this comment.
Favor de actualizar todos los 65 a 'A'.charCodeAt(0) al igual que el 90, 97, 122 a sus respectivos valores.
js/app.js
Outdated
| } else if (origCode >= 97 && origCode <= 122) { | ||
| newCode = (origCode - 97 + x) % 26 + 97; | ||
| newLetter = String.fromCharCode(newCode); | ||
| msg = msg.slice(0, i) + newLetter + msg.slice(i + 1, msg.length); |
There was a problem hiding this comment.
En vez de actualizar el msg una y otra vez, por que no usas una variable nueva para el mensaje nuevo y puedes usar += para aniadir chars uno por uno.
js/app.js
Outdated
| newCode = msg.charCodeAt(i); | ||
| // Si el caracter es mayuscula se encuentra entre los codigos 65 y 90 | ||
| if (newCode >= 65 && newCode <= 90) { | ||
| if ((newCode - x % 26) < 65) |
There was a problem hiding this comment.
agregar curly brackets despues del if condition.
js/app.js
Outdated
| if (newCode >= 65 && newCode <= 90) { | ||
| if ((newCode - x % 26) < 65) | ||
| origCode = 90 - (x % 26) + (newCode - 65) + 1; | ||
| else |
There was a problem hiding this comment.
Agregar curly braces despues del else.
js/app.js
Outdated
| origLetter = String.fromCharCode(origCode); | ||
| msg = msg.slice(0, i) + origLetter + msg.slice(i + 1, msg.length); | ||
| } else if (newCode >= 97 && newCode <= 122) { // Si el caracter es minuscula se encuentra entre los codigos 97 y 122 | ||
| if ((newCode - x % 26) < 97) |
| if ((newCode - x % 26) < 97) | ||
| origCode = 122 - (x % 26) + (newCode - 97) + 1; | ||
| else | ||
| origCode = (newCode - x % 26); |
js/app.js
Outdated
| // Llamar función cipher | ||
| if (msg !== '') { | ||
| cipher(msg, 33); | ||
| break; // break para salir del bucle |
There was a problem hiding this comment.
break no es necesario aqui. Generalmente se usa en switch statements o en loops. En realidad no esta haciendo nada aqui.
| } | ||
|
|
||
| // Creando función para descrifrar | ||
| function decipher(msg, x) { |
There was a problem hiding this comment.
Creo que no es necesario pasar el variable x.
Solo llamas esta function una vez y le das un valor de 33.
| @@ -0,0 +1,90 @@ | |||
| // Creando funcion Cifrado Cesar | |||
| function cipher(msg, x) { | |||
There was a problem hiding this comment.
Segun las especificaciones, el usuario no debe poder ingresar numeros. Trate de poner numeros en mi mensaje y si pude. Favor de actualizar el code para que no pueda ingresar numeros en el mensaje
Creo que no es necesario pasar el variable x.
Solo llamas esta function una vez y le das un valor de 33.
Hola, soy Andrea, espero sus comentarios sobre mi código.
Gracias.