- Notifications
You must be signed in to change notification settings - Fork6.7k
[PTMAD1018][LUCIA.CAZORLA]#697
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
Removed duplicated text
Extra Resources added
…with-teststarter-code-with-tests
…one" but the test is expecting for the string itself, i change the Readme file wich is the quck fix, but may be could be good to change the spec file to not confuse the student.
…tion-fixthe test are waiting for undefined but the description says false
…rd-fixfind-longest-word-little-fix
ta-web-mad left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Échale un ojo a los comentarios que te he puesto, me ha gustado que reutilices funciones y que hayas creado funciones más pequeña para hacer alguna tarea concreta. Intenta cuando puedas el último ejercicio, que es una buena práctica. Buen ejercicio, sigue así! 🌵
} else if (n1 < n2){ | ||
return n2; | ||
} else return n1; | ||
} |
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.
Te sobran elelse if
y el últimoelse
, ten en cuenta que si no se cumple la primera condición, significará que el segundo número es mayor y, en el caso de ser iguales, puedes devolver el segundo también;
function max(a, b) { if(a > b) return a return b}
Si te apetece, échale un ojo a la funciónmax( )
de la claseMath
, que hace justo eso, devolver el número mayor de un conjunto de números que reciba como parámetro
function averageNumbers (numbers){ | ||
var average; | ||
if (!numbers.length){ | ||
average = undefined; |
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í, en vez de igualar average aundefined
, podías simplemente devolver nada con unreturn
, eso hace que se corte la ejecución de la función y además devuelvasundefined
if (!numbers.length){ | ||
average = undefined; | ||
} else if (numbers.length === 1){ | ||
average = numbers[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.
Haciendo la media no te sobraría este bloqueif
? Si hay un solo elemento en el array, la media de un solo elemento es el valor de ese único elemento
average = undefined; | ||
} else if (words.length === 1){ | ||
average = words [0].length; | ||
} else { average = lenghtSum (words) / words.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.
En esta función te digo lo mismo que antes, sobre devolverundefined
si el array está vacío y sobre el bloqueif
que sobra cuando el array solo tiene un elemento.
function howManyTimes (words, word){ | ||
if (words.length === 0){ | ||
return false; | ||
} 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.
La definición del bloqueelse
sobra, con elreturn
del if se corta la ejecución de la función si llega a cumplir la condición
Aún no está terminado, con fallos.