- Notifications
You must be signed in to change notification settings - Fork6.7k
[webptmat0418] - Alma y Rulo (+bonus quest)#361
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
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.
Buen trabajo, seguid así! 👍
}else{ | ||
returnb; | ||
} | ||
} |
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 correcto, para ahorrar alguna línea, podéis no poner el else, y dejar el return b, ya que si cumple la condición, sale de la función por el return, y si no, devuelve b. Otra manera de hacer el ejercicio, echadle un ojo a Math.max( )
} | ||
} | ||
returnlongest; | ||
} |
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.
Muy bien!
const reducer = (accumulator, currentValue) => accumulator + currentValue; | ||
return numbers.reduce(reducer); | ||
} | ||
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.
Bien ambas, tanto la manual como la comentada. En el caso de hacerlo con reduce, cuidado con la sobreabstracción. Llamais a una función reducer dentro de reduce dentro de una función. Quizás sea demasiado para algo tan pequeño. Y no utiliceis arrow function todavía, que es ES6 y aún no lo hemos dado en el bootcamp
sum+=word.length; | ||
}); | ||
returnsum/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.
Muy bien, aquí también podeis usar reduce (o reutilizar el método para sumar que hiciste antes)
} | ||
}); | ||
returnresult; | ||
} |
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.
Bien hecho. Varias cositas sobre el código. Podéis hacer que itere menos usando un bucle for y haciendo 'return true' cuando cumpla la condición. Y digo for y no forEach, porque el problema de map( ) y forEach( ) es que no dejan de iterar ante un break o un return. Cuando se encuentran con break o return, solo saltan esa iteración y pasan a la siguiente. Así podéis dejar de comprobar más nombres cuando ocurra la condición en vez de iterar sobre todos los nombres independientemente de que se cumpla la condición.
} | ||
} | ||
returncount; | ||
} |
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.
Genial, también podéis usar indexOf( ) o includes( ), echadle a cómo hacerlo con ambos
} | ||
greatestProduct(matrix); | ||
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.
Muy bien, es correcto. Solo puedo poner una pega, es muy largo incluso sin los console log, cómo lo podríais hacer más corto?
No description provided.