-
Notifications
You must be signed in to change notification settings - Fork 116
Cifrado Cesar - Manuela Flores #81
base: master
Are you sure you want to change the base?
Conversation
@developerVilchez |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
¡Gran trabajo! Solo tengo algunos pequeños comentarios.
// convirtiendo la cadena de texto a mayúsculas | ||
string = string.toUpperCase(); | ||
// newPosition:almacenará las posiciones en el código ASCII de la cadena de texto | ||
var newPosition = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Es posible combinar estos dos loops en uno:
var newString = '';
for (var i = 0; i < string.length; i++) {
// agregando las posiciones de las letras del string en codigo ASCII a newPosition
var newPosition = (string.charCodeAt(i) - 13 - 33) % 26 + 65);
newString += String.fromCharCode(newPosition);
}
// concantenando las letras encriptadas a newString | ||
newString += String.fromCharCode(newPosition[j]); | ||
} | ||
return alert('Su frase descifrada es ' + newString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Es importante que la función devuelta una cadena. Si quieres usar un alert, usarlo antes del return
:
alert('Su frase descifrada es ' + newString);
return newString;
// convirtiendo la cadena de texto a mayúsculas | ||
string = string.toUpperCase(); | ||
// newPosition:almacenará las posiciones en el código ASCII de la cadena de texto | ||
var newPosition = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Es posible combinar los dos loops en uno (vea abajo)
newString += String.fromCharCode(newPosition[j]); | ||
} | ||
// retornando cadena de texto encriptada | ||
return alert('Sufrase crifrada es ' + newString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Es importante que la función devuelta una cadena. Si quieres usar un alert, usarlo antes del return:
alert('Su frase cifrada es ' + newString);
return newString;
Muchas gracias por revisar mi producto final , espero recibir feedback pronto :)