Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions JS/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var phrase = prompt('Write here');

function cipher(word) {

var strCipher = '' ;
for (var i = 0; i < word.length; i++) {
// turn word into ASCII code.
Expand All @@ -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 +=

// if 'word' is lowercase...
} else if (Number.isNaN(parseInt(word)) && 97 <= letter && letter <= 122 && word !== '') {
// using the formula.
Expand All @@ -29,7 +28,7 @@ cipher(phrase);

function decipher(word) {
var strDecipher = '' ;
for (var i = 0; i < word.length; i++ ) {
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.

Expand Down