-
Notifications
You must be signed in to change notification settings - Fork 116
Corrigiendo indentacion #75
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
}, | ||
"rules": { | ||
"keyword-spacing": 1, | ||
"space-before-function-paren": [1, "never"], | ||
"eqeqeq": 1, | ||
"space-infix-ops": 1, | ||
"comma-spacing": 1, | ||
"brace-style": 1, | ||
"no-multiple-empty-lines": 1, | ||
"camelcase": 1, | ||
"func-call-spacing": 1, | ||
"key-spacing": 1, | ||
"semi": 1, | ||
"no-floating-decimal": 1, | ||
"no-multi-spaces": 1, | ||
"object-property-newline": 1, | ||
"padded-blocks": [1, "never"], | ||
"space-before-blocks": 1, | ||
"space-in-parens": 1, | ||
"spaced-comment": 1, | ||
"quotes": [1, "single"], | ||
"id-length": [1, { "exceptions": ["i", "j", "x"] }], | ||
"indent": [1, 2], | ||
"no-array-constructor": 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Cifrado Cesar</title> | ||
</head> | ||
<body> | ||
<script type="text/javascript" src = "app.js"> | ||
|
||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
function cipher(word) { | ||
var word = prompt('Ingrese la frase'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. El prompt debe ser fuera de la función, y después puedes llamar el función así:
(Este puede estar en la línea 40) |
||
// ingreso de la palabra | ||
|
||
// Validadno que la cadena no este vacia | ||
if (word === ''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No necesitas ; aquí There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (El |
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. { debe estar en la línea anterior |
||
alert('Tienes que ingresar una frase'); | ||
} | ||
// Validando que solo permita el ingreso de letras minusculas y mayusculas | ||
|
||
if ((word.charCodeAt() >= 97 && word.charCodeAt() <= 122) || (word.charCodeAt() >= 65 && word.charCodeAt() <= 90)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. charCodeAt necesita un parametro - el índice del caracter en la cadena. Si no usas parametro, el índice predeterminado es 0 - entonces, este código solo verifica la primera letra de la cadena. https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/String/charCodeAt |
||
alert('muy bien'); | ||
} else { | ||
alert('No es valido ingresar numeros'); | ||
} | ||
|
||
var wordTemp = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pienso que puedes elegir mejor nombre por esta variable. Por ejemplo, |
||
var wordCipher = ''; // Se define para almacenara la palabra cifrada | ||
var codeAscii = 0;// variable donde se guarda el codigo correspondiente a cada letra en ascii | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pon un espacio antes del // |
||
for (var i = 0; i < word.length; i++) { | ||
codeAscii = word.charCodeAt(i); // para obtener el codigo ascii de una palabra ingresada | ||
if (codeAscii >= 65 && codeAscii <= 90) // Para letras mayusculas | ||
wordTemp = (word.charCodeAt(i) - 65 + 33) % 26 + 65; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Elimina esta línea en blanco |
||
|
||
// Para letras minusculas | ||
else { | ||
(codeAscii >= 97 && codeAscii <= 122); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esta línea no hace nada. ¿Querías escribir |
||
wordTemp = (word.charCodeAt(i) - 65 + 33) % 26 + 97; | ||
} | ||
wordCipher += (String.fromCharCode(wordTemp)); | ||
|
||
// se va almacenando uno por uno de acuerdo a la cantidad de letras de la palabra que se ingreso | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Este comentario tiene más sentido antes del loop (antes de la línea 21). |
||
} | ||
|
||
return wordCipher;// retorna la salida de la palabra cifrada | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pon un espacio antes del // |
||
} | ||
|
||
console.log(cipher('a')); | ||
|
||
|
||
function decipher(word) { | ||
var word = prompt('Ingrese la frase');// ingreso de la palabra | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hay el mismo problema que la función cipher - este |
||
// Validadno que la cadena no este vacia | ||
if (word === '') { | ||
alert('Tienes que ingresar una frase'); | ||
} | ||
// Validando que solo permita el ingreso de letras minusculas y mayusculas | ||
|
||
if ((word.charCodeAt() >= 97 && word.charCodeAt() <= 122) || (word.charCodeAt() >= 65 && word.charCodeAt() <= 90)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. charCodeAt() necesita parametro |
||
alert('muy bien'); | ||
} else { | ||
alert('No es valido ingresar numeros'); | ||
} | ||
var word = prompt('Ingrese la frase'); | ||
var wordTemp = 0; | ||
var wordCipher = ''; // Se define para almacenara la palabra decifrada | ||
var codeAscii = 0;// variable donde se guarda el codigo correspondiente a cada letra en ascii | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Espacio antes de // |
||
for (var i = 0; i < word.length; i++) { | ||
codeAscii = word.charCodeAt(i); // para obtener el codigo ascii de una palabra ingresada | ||
// Para letras mayusculas | ||
if (codeAscii >= 65 && codeAscii <= 90) { | ||
wordTemp = ((word.charCodeAt(i) - 33) % 26) ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Elimina el espacio antes de ; |
||
// Para letras minusculas | ||
} else { | ||
(codeAscii >= 97 && codeAscii <= 122); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esta línea no hace nada - ¿necesitas |
||
wordTemp = ((word.charCodeAt(i) - 33) % 26) ; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Elimina esta línea en blanco |
||
|
||
wordCipher += (String.fromCharCode(wordTemp)); // se va almacenando uno por uno de acuerdo a la cantidad de letras de la palabra que se ingreso | ||
} | ||
|
||
return wordCipher; // retorna la salida de la palabra decifrada | ||
} | ||
// console.log(decipher ('Alas')); |
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 uses espacios sobre el
=