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

Añadiendo arreglos con EsLint #80

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

Conversation

Azur-Azabache
Copy link

Pamela Rojas

@Gabx04
Copy link

Gabx04 commented Nov 10, 2017

@developerVilchez eslint OK

Copy link
Collaborator

@nicolethenerd nicolethenerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¡Gran comienzo! Tu código está bien organizado y es fácil de leer. Desfortunadamente, todavía no funciona para cifrar y decifrar strings.

Las funciones cipher y decipher debe devolver strings, por ejemplo:

cipher('HOLA'); // --> 'OVSH' decipher('OVSH'); // --> 'HOLA'

JS/app.js Outdated
@@ -0,0 +1,28 @@
var phrase = prompt('Ingresa la frase a decodificar');
var newarray = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS/app.js Outdated

function cipher(str) {
var array = phrase.split('');
for (i = 0; i <= array.length - 1;i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usa 'var' para declarar una nueva variable
for (var i = 0;

espacio antes de i++
for (i = 0; i <= array.length - 1; i++) {

JS/app.js Outdated
var newarray = [];
var unicode = [];

function cipher(str) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No estás usando este parámetro 'str'
Debes reemplazar 'phrase' con 'str' dentro de esta función

JS/app.js Outdated

function cipher(str) {
var array = phrase.split('');
for (i = 0; i <= array.length - 1;i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefiero i < array.length a i <= array.length - 1

JS/app.js Outdated
@@ -0,0 +1,28 @@
var phrase = prompt('Ingresa la frase a decodificar');
var newarray = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es importante que declares newarray dentro de la función cipher (por ejemplo, en la linea 6). De lo contrario, si ejecutas el código dos veces, el arreglo contendrá letras de ambas palabras.

JS/app.js Outdated
}
return newarray;
}
var arr = cipher(phrase);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La resulta de la función cipher debe ser un string - esta variable sería mejor llamada algo así como encodedPhrase.

JS/app.js Outdated
return newarray;
}
var arr = cipher(phrase);
function decipher(array2) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El parámetro aquí debe ser string. decipher debe funcionar como así:
decipher('OVSH'); // --> 'HOLA'

JS/app.js Outdated
var arr2 = [];
for (i = 0; i <= array2.length - 1; i++) {
arr2.push(String.fromCharCode(array2[i]));
return arr2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El return debe ser fuera del loop. Ahora, esta función devuelta el arreglo después del primer iteración del loop.

JS/app.js Outdated
}
if (isNaN(phrase) === false) {
'Ingrese una frase por favor';
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No necesitas una else vacío.

JS/app.js Outdated
arr2.push(String.fromCharCode(array2[i]));
return arr2;
}
if (isNaN(phrase) === false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Qué está tratando de hacer aquí? Este código prueba si phrase es un número.

También, no necesitas === false - puedes usar un !, así :
if (!isNaN(phrase))

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.

4 participants