Skip to content

[PTREMOTE] Maria Belen Colturi - lab-javascript-functions-and-arrays #3853

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Maria-colturi
Copy link

No description provided.

return null;
}
let longest = words[0];
for (let i = 0; i < words.length; i++) {

Choose a reason for hiding this comment

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

Suggested change
for (let i = 0; i < words.length; i++) {
for (let i = 1; i < words.length; i++) {

Si te fijas la primera posicion ya la estas cogiendo antes, asi que compararla consigo misma pues como que no tiene mucho sentido jejeje

let sum = 0;
for (let i = 0; i < numbers.length; i++) {
const currentNumber = numbers[i]
console.log(currentNumber);

Choose a reason for hiding this comment

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

Suggested change
console.log(currentNumber);

Esto son pijadas pero vamos siempre que puedas quitar los console.log es bien :D

Comment on lines +47 to +52
let sum = 0;
for (let i = 0; i < numbers.length; i++) {
currentNumber = numbers[i]
sum += currentNumber
}
return sum

Choose a reason for hiding this comment

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

Este metodo y el anterior de sumNumbers se parecen mucho, tirando a que son iguales, creo que en el ejercicio o los test te iba poniendo los diferentes puntos que tenias que tocar, por ejemplo si justo el elemento que estabas iterando era un string, o si era un booleano, objeto, etc

Miratelo si puedes y si tienes alguna duda me dices vale??

function averageNumbers() {}
function averageNumbers(numbersAvg) {
let average = 0;
if (numbersAvg = [""]) {

Choose a reason for hiding this comment

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

Suggested change
if (numbersAvg = [""]) {
if (numbersAvg.length === 0) {

Creo que en los test te dice si el array esta vacio, devuelve null, pues si te fijas tu habias igualado la variable (hubieses necesitado los tres iguales (===) para que fuera una pregunta buena buena jejej) y luego has preguntado porque el array tuviera una posicion y que en esa posicion tuviera un string vacio o "", por ello la mejor forma de saber si un array esta vacio es preguntar por su length y preguntar si ese length es 0, asi te aseguras que ese array AKA "bolsa" esta vacia, si no tiene nada pues esta vacia !!

Comment on lines +65 to +69
for (let i = 0; i < numbersAvg.length; i++) {
const element = numbersAvg[i];
average += element
return average / numbersAvg.length
}

Choose a reason for hiding this comment

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

Suggested change
for (let i = 0; i < numbersAvg.length; i++) {
const element = numbersAvg[i];
average += element
return average / numbersAvg.length
}
for (let i = 0; i < numbersAvg.length; i++) {
const element = numbersAvg[i];
average += element
}
return average / numbersAvg.length

Si lo pones dentro del for, cuando pase una vez, pues ya no sale del bucle! por eso dejamos que el bucle termine y luego retornamos el resultado! :D

Comment on lines +82 to +86
for (let i = 0; i < wordsArray.length; i++) {
const word = wordsArray[i].length;
wordAverage += word
return wordAverage / wordsArray.length
}

Choose a reason for hiding this comment

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

Suggested change
for (let i = 0; i < wordsArray.length; i++) {
const word = wordsArray[i].length;
wordAverage += word
return wordAverage / wordsArray.length
}
for (let i = 0; i < wordsArray.length; i++) {
const word = wordsArray[i].length;
wordAverage += word
}
return wordAverage / wordsArray.length

Lo mismo que antes :D

Copy link
Author

Choose a reason for hiding this comment

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

Gracias por los comentarios Cristian, voy a seguir practicando

@stale
Copy link

stale bot commented Jul 15, 2023

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.

@stale stale bot added the stale label Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants