-
Notifications
You must be signed in to change notification settings - Fork 116
lauravelarde-caesar-cipher #77
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,13 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <title>Cipher Cesar</title> | ||
| </head> | ||
| <body> | ||
| <h2 style='font-family:Tahoma;color:blueviolet'>The first word is encrypted and the second word is decrypted </h2> | ||
| <script type='text/javascript' src='js/app.js'></script> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| var word = prompt('Write a word to encrypt'); | ||
| function cipher(string) { | ||
| // Creamos una variable vacia para almacenar el string encriptado// | ||
|
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. indenta esta línea - los comentarios debe estar alineados con el código |
||
| var newString = ''; | ||
| // Iteramos cada caracter del string | ||
| for (var i = 0; i < word.length; i++) { | ||
| // Almacenamos el codigo ASCII de cada caracter | ||
| var encrypter = word.charCodeAt(i); | ||
|
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 nombre 'encrypter' no describe que hace esta variable. Algo como |
||
| // Verificamos si las letras son mayusculas. | ||
| if (encrypter >= 65 && encrypter <= 90) { | ||
| // Aplicamos la formula para obtener el codigo ASCII | ||
| var letters = (encrypter - 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. Esta variable también sería nombrado mejor - como |
||
| // Convertimos el codigo ASCII en letra encriptada y lo unimos al string vacío | ||
| newString += String.fromCharCode(letters); | ||
| } else if (encrypter >= 97 && encrypter <= 122) { // Repetimos el procedimiento si son minusculas. | ||
| var lettersTwo = (encrypter - 97 + 33) % 26 + 97; | ||
| newString += String.fromCharCode(lettersTwo); | ||
| } else if (typeof string !== String) { // Verificamos que el usuario no ingrese un numero o campo vacio | ||
| alert('You have not entered a word'); | ||
| } | ||
| } | ||
| return newString; | ||
| } | ||
| // Llamamos a la funcion | ||
| document.write(cipher('word')); | ||
|
|
||
| var word = prompt('Write a word to decode'); | ||
| function decipher(string) { | ||
| // Creamos una variable vacia para almacenar el string encriptado | ||
| var newString = ' '; | ||
|
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. Eliminar el espacio blanco dentro de las comillas |
||
| // Iteramos cada caracter del string | ||
| for (var i = 0; i < word.length; i++) { | ||
| // Almacenamos el codigo ASCII de cada caracter | ||
| var encrypter = word.charCodeAt(i); | ||
|
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. Tengo los mismos comentarios que los anteriores sobre los nombres de las variables en esta función |
||
| // Verificamos si las letras son mayusculas. | ||
| if (encrypter >= 65 && encrypter <= 90) { | ||
| // Aplicamos la formula para obtener el codigo ASCII | ||
| var letters = (encrypter - 65 - 33) % 26 + 65; | ||
| // Convertimos el codigo ASCII en letra encriptada y lo unimos al string vacío | ||
| newString += String.fromCharCode(letters); | ||
| } else if (encrypter >= 97 && encrypter <= 122) {// Repetimos el procedimiento si son minusculas. | ||
| var lettersTwo = (encrypter - 97 - 33) % 26 + 97; | ||
| newString += String.fromCharCode(lettersTwo); | ||
| } else if (typeof string !== String) {// Verificamos que el usuario no ingrese un numero o campo vacio | ||
| alert('You have not entered a word'); | ||
| } | ||
| } | ||
| return newString; | ||
| } | ||
| // Llamamos a la funcion | ||
| document.write(decipher('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.
Es mejor usar un archivo .css que un atributo
style