-
Notifications
You must be signed in to change notification settings - Fork 5.6k
cluedo terminado #3724
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
cluedo terminado #3724
Conversation
| // ITERATION 2 | ||
|
|
||
| function selectRandom() {} | ||
| function selectRandom(room, weapon, suspect) { |
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 importante hacerlo en una sola función, ya que de esta manera estas repitiendo código. Fijate que haces un Math.floor y la siguiente lineas accedes al array y lo pusheas.
Sería mucho más fácil si pasandole un array la función te devuelve un elemento.
|
|
||
|
|
||
|
|
||
| function pickMystery() {} |
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.
Esta función debería llamar a selectRandom asignar la respuestas a diferentes constantes. Por ejemplo; suspect, room, weapon y después de eso pasarle un objeto ya compuesto a revealMystery. De esta manera revealMystery no necesita saber en que posición del array viene cada cosa sino acceder directamente al objeto.
Imagina que llamas al parámetro mystery.
Podrias acceder de la siguiente manera: mystery.suspect.firstName, mystery.suspect.lastName, mystery.weapon.name y mystery.room.name
j0nl1
left a comment
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 he dejado unos comentarios con una sugerencia de cambios para que pruebes esta implementación y veas la diferencia.
|
This pull request has been automatically marked as stale because it didn't have any recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
en vez de hacer 2 funciones una para seleccionar y otra para crear el array lo hice todo en una.