-
Notifications
You must be signed in to change notification settings - Fork 116
subiendo mis archivos #72
base: master
Are you sure you want to change the base?
Conversation
Hola @EstrellaBF está pendiente un detalle para poder enviar tu var phrase = prompt('Write here');
function cipher(word) {
var strCipher = '' ;
for (var i = 0; i < word.length; i++) {
// turn word into ASCII code.
var letter = word.charCodeAt(i);
// if 'word' is uppercase...
if (Number.isNaN(parseInt(word)) && 65 <= letter && letter <= 90 && word !== '') {
// using the formula.
var num = (letter - 65 + 33) % 26 + 65;
// num into string
strCipher += String.fromCharCode(num);
// if 'word' is lowercase...
} else if (Number.isNaN(parseInt(word)) && 97 <= letter && letter <= 122 && word !== '') {
// using the formula.
var num2 = (letter - 97 + 33) % 26 + 97;
// num into string
strCipher = strCipher + String.fromCharCode(num2);
} else {
alert('Write Again, please.');
}
}
return alert(strCipher);
}
cipher(phrase);
function decipher(word) {
var strDecipher = '' ;
for (var i = 0; i < word.length; i++) {
var letter = word.charCodeAt(i);
if (Number.isNaN(parseInt(word)) && 65 <= letter && letter <= 90 && word !== '') {
// añadir la formula y almaceno en num
var num = (letter - 65 + 26) % 26 + 65;
strDecipher = strDecipher + String.fromCharCode(num);
} else if (Number.isNaN(parseInt(word)) && 97 <= letter && letter <= 122 && word !== '') {
var num2 = (letter - 97 + 26) % 26 + 97;
strDecipher = strDecipher + String.fromCharCode(num2);
} else {
alert('Write Again, please.');
}
}
return alert(strDecipher);
}
decipher(phrase); |
Hola, buenos días. Use el slint y supuestamente estaba todo bien.
Consultare y te actualizó la información :)
El nov. 14, 2017 9:14 AM, "Gabriela Segura" <[email protected]>
escribió:
… Hola @EstrellaBF <https://github.com/estrellabf> está pendiente un
detalle para poder enviar tu pull request a los googlers,
te dejo tu código según la guía de estilo, recuerda usar el eslint.
Por favor actualiza el tuyo y me confirmas.
var phrase = prompt('Write here');
function cipher(word) {
var strCipher = '' ;
for (var i = 0; i < word.length; i++) {
// turn word into ASCII code.
var letter = word.charCodeAt(i);
// if 'word' is uppercase...
if (Number.isNaN(parseInt(word)) && 65 <= letter && letter <= 90 && word !== '') {
// using the formula.
var num = (letter - 65 + 33) % 26 + 65;
// num into string
strCipher += String.fromCharCode(num);
// if 'word' is lowercase...
} else if (Number.isNaN(parseInt(word)) && 97 <= letter && letter <= 122 && word !== '') {
// using the formula.
var num2 = (letter - 97 + 33) % 26 + 97;
// num into string
strCipher = strCipher + String.fromCharCode(num2);
} else {
alert('Write Again, please.');
}
}
return alert(strCipher);
} cipher(phrase);
function decipher(word) {
var strDecipher = '' ;
for (var i = 0; i < word.length; i++) {
var letter = word.charCodeAt(i);
if (Number.isNaN(parseInt(word)) && 65 <= letter && letter <= 90 && word !== '') {
// añadir la formula y almaceno en num
var num = (letter - 65 + 26) % 26 + 65;
strDecipher = strDecipher + String.fromCharCode(num);
} else if (Number.isNaN(parseInt(word)) && 97 <= letter && letter <= 122 && word !== '') {
var num2 = (letter - 97 + 26) % 26 + 97;
strDecipher = strDecipher + String.fromCharCode(num2);
} else {
alert('Write Again, please.');
}
}
return alert(strDecipher);
} decipher(phrase);
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#72 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ae0Dmwjxvl5siJD5IlkkTLG-8SCvE-Etks5s2aBdgaJpZM4QVUcR>
.
|
@developerVilchez |
JS/app.js
Outdated
@@ -11,7 +10,7 @@ function cipher(word) { | |||
// using the formula. | |||
var num = (letter - 65 + 33) % 26 + 65; | |||
// num into string | |||
strCipher =+ String.fromCharCode(num); | |||
strCipher = + String.fromCharCode(num); |
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.
manten esto como +=
JS/app.js
Outdated
} | ||
return alert(strCipher); | ||
} | ||
cipher(phrase); |
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.
No deberias de cifrar a menos que el usuario lo pida. Puedes hacer un menu donde el usuario pueda ingresar "1" para cifrar o "2" para descifrar
JS/app.js
Outdated
for (var i = 0; i < word.length; i++ ) { | ||
var letter = word.charCodeAt(i); | ||
|
||
if (Number.isNaN(parseInt(word)) && 65 <= letter && letter <= 90 && word !== '') { |
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.
parseInt va a regresar NaN por cualquier cosa incluyendo chars como estos: @#%^&@#$:{}".
Por que no haces un helper function que regrese un boolean de true cuando el texto sea solamente letras y espacios y false cuando tenga otros chars que no sean letras y espacios.
JS/app.js
Outdated
var num2 = (letter - 97 + 26) % 26 + 97; | ||
strDecipher = strDecipher + String.fromCharCode(num2); | ||
} else { | ||
alert('Write Again, please.'); |
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.
Me sale una alerta de "write again, please" por cada numero que ponga en el mensaje!
JS/app.js
Outdated
var num = (letter - 65 + 26) % 26 + 65; | ||
|
||
strDecipher = strDecipher + String.fromCharCode(num); | ||
} else if (Number.isNaN(parseInt(word)) && 97 <= letter && letter <= 122 && word !== '') { |
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.
cambia los valores de ASCII de las letras por 'A'.charCodeAt(0) con cada letra
No description provided.