Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

subiendo mis archivos #72

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

EstrellaBF
Copy link

No description provided.

Verified

This commit was signed with the committer’s verified signature.
pupnewfster Sara Freimer
@Gabx04
Copy link

Gabx04 commented Nov 14, 2017

Hola @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);

@EstrellaBF
Copy link
Author

EstrellaBF commented Nov 14, 2017 via email

@Gabx04
Copy link

Gabx04 commented Nov 16, 2017

@developerVilchez eslint OK.

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);
Copy link

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);
Copy link

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 !== '') {
Copy link

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.');
Copy link

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 !== '') {
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants