Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[webptmat0418] - Georgina & Carlos #366

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

Closed
wants to merge 20 commits into from

Conversation

Georginapacey
Copy link

We finished the last function (bonus quest) at home independently so I we reviewed each other's function, I have put both in the code

Copy link
Contributor

@ta-web-mad ta-web-mad left a comment

Choose a reason for hiding this comment

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

Dadle un repasillo e intentad hacer el ejercicio del array 2d de nuevo. Ánimo!

}


}
Copy link
Contributor

Choose a reason for hiding this comment

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

Muy bien, echadle un ojo a Math.max( ) y recordad que return te saca de la función, así que podéis quitar el else y dejar el 'return b' fuera

words.splice(secondPosition, 1)
}
}
return words;
Copy link
Contributor

Choose a reason for hiding this comment

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

Es correcto, también podéis hacer la evaluación con el indexOf( ) dentro, así ahorráis algunas líneas. Probad a ver si os gusta :D

}

return wordExists;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Muy bien, el método includes( ) es súper útil también para realizar este ejercicio, echadle un ojo

} else {
return repetitionCounter;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Supongo que la comprobación de la línea 183 es si 'array' está vacío. La evaluación se hace con '==' o con '===', no con un solo '='. Y es más efectivo que lo hagáis al principio de la función, porque así no ejecutáis más código de la cuenta. Y también es mejor si la evaluación la hacéis con 'array.length' ya que si es igual a 0, la evaluación se toma como false y podéis continuar con el return false.

También podéis probar a hacer con un filter( ) y un length a dicho filter, a ver si os gusta

}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Varias cosas; falta el return, con lo que si llamamos a la función no devuelve nada. El límite de ambos for no debes marcarlos con 20. Aunque sepas que la prueba se hace con un array 2d de 20 x 20, puedo darte un array más grande o más pequeño; así que mejor usad array.length como tope.

Más cositas, el ejercicio no devuelve el resultado correcto, ya que el valor que almacena tu variable 'valor' es el del valor único más alto (da como resultado 99) y no el del producto de los cuatro adyacentes más alto. Aunque tienes un for para multiplicar los valores adyacentes, éste no da buen resultado porque ese array siempre tiene un único elemento. Vuestro fallo está probablemente en todos los if...else, ya que solo entra en una evaluación cada vez y hace un solo push por vuelta.

}
return highestProduct;
}
}*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Y aquí me temo que el resultado tampoco es el correcto, os recomiendo probar con arrays 2d que cumplan el mínimo, como uno de 4 x 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.