- Notifications
You must be signed in to change notification settings - Fork6.7k
MAD PT Cesar Aparicio#183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
if (first>second){ | ||
console.log(first); | ||
} | ||
else ("");{ |
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.
para los else no se necesita poner nada if(condición) { } else { }
return; | ||
} | ||
for (var sum=0, i=0; i <= words.length; i++) { | ||
sum += words[i]; |
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.
estás añadiendo la palabra a la variable sum, le estás diciendo que por ejemplo en la primera iteración "seat", sum += "0seat", luego "correspond", por lo que en la segunda iteración vale "0seatcorrespond" y así sucesivamente. Por lo que luego no puedes operar con un string
"crackpot" | ||
]; | ||
var differ = 0; | ||
//¿for(var i=0; esto es una variante de i = 0? |
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.
sí, declaras una variable para el bucle for, aquí lo que harías es sobre escribir una variable que esté por encima en el código. Siempre declaralá dentro del bucle
//¿for(var i=0; esto es una variante de i = 0? | ||
for (i = 0; i < words.length; i++) { | ||
if(words[i].length > differ) { | ||
var differ = words[i].length; |
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.
estás volviendo a declarar la variable con el nombre differ, por lo que estás sobreescribiendo la variable de la línea 51. si quieres asignar un valor a la variable de arriba deberías hacerlo sin la palabra reservada var
for (i = 0; i < words.length; i++) { | ||
if(words[i].length > differ) { | ||
var differ = words[i].length; | ||
words = words[i]; |
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.
en esta linea le estás diicnedo que "words" que es el array que estás iterando, vale la primera palabra del array en la primera iteración, por lo que luego el bucle iterará solo por las letras de esta palabra
"simple", | ||
"bring"]; | ||
words = words.filter( function( item, index, inputArray ) { |
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.
aquí no estás haciendo ninguna modificación, le estás pasando words, y le estás diciendo que te devuelva el mismo array, porque iterará sobre los elementos de este array uno a uno, y siempre coincide el index con la palabra buscada en el indexOf()
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.
checked! revisa los comentarios Cesar. Ánimo!
(Juan Macías: ) Entrega fuera de fecha por problemas con github. Solucionado 02/11/17.
Pendiente corrección.