Skip to content

[WEB-MAD-PT-APRIL-2021] Elizabeth Colastra #2342

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 12 commits into from

Conversation

AriadnaNatsuki
Copy link

No description provided.

@@ -1,73 +1,239 @@
// Iteration #1: Find the maximum
// Iteration #1: Find the maximum
function maxOfTwoNumbers(num1, num2) {
return num1 > num2 ? num1 : num1 == num2 ? num2 : num2;
Copy link

Choose a reason for hiding this comment

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

Aunque esto es correcto, es dificil de leer. Para ello es mejor el uso del if-else. Igualmente me alegro que consiguieras hacerlo con un ternario.

Copy link

Choose a reason for hiding this comment

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

No es más eficiente, realmente haces lo mismo, una condicional, lo único que cambia es la forma de escribirlo. Sería igual si lo hiciésemos con if-else y return dentro de estos.

Comment on lines +20 to +38
switch (array.length) {
case 0:
return null
break
case 1:
return array[0]
break
default:
for (let i = 1; i < array.length; i++) {

//Si la longitud del string longest no es mayor que el elemento array[i], el elemento array[i] será de mayor longitud y por tanto le asignaremos al string longest dicho elemento
//Si longest es menor que el array o si no es mayor
//!longest.length >= array[i].length? longest==array[i];
if (!(longest.length >= array[i].length)) {
longest = array[i];
}
}
return longest;
}
Copy link

Choose a reason for hiding this comment

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

Una forma muy original de conseguirlo. Me gusto 🔝

Comment on lines +60 to +62
return array.reduce(function (valorAnterior, valorActual) {
return valorAnterior + valorActual;
}, 0);
Copy link

Choose a reason for hiding this comment

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

Aunque es correcto del reduce es correcto, intenta no utilizar metodos que aún no se han explicado en clase.

Copy link

Choose a reason for hiding this comment

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

El ejercicio te dice que existe esa manera pero que es preferible que ahora se trabaje con los bucles. Lo que se intenta es persuadir de utilizarlo.

Comment on lines +51 to +58
let contador = 0;
for (let i = 0; i < array.length; i++) {
if (array[i] === 0) {
contador++;
}
}
if (contador == array.length) {
return 0;
Copy link

Choose a reason for hiding this comment

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

Está parte del código no haría falta, ya que si nuestra función se ejecuta correctamene si sumamos 0 + 0 + 0 + 0 nos debería de devolver 0.

Copy link

Choose a reason for hiding this comment

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

Todo lo contrario, si esta condición no se cumple obligamos a nuestro código a recorrer dos veces el mismo array, una para comprobar si todos son 0 y otra si en algún caso esto no se cumple lo vuelvo a recorrer para sumarlos. Cuando recorrerlo una única vez podemos obtener el resultado.

// }

//Opción B
//return array.forEach(element => sum + element)
Copy link

Choose a reason for hiding this comment

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

Cuidado que un forEach siempre devuelve undefined.

Copy link

@Kunry Kunry left a comment

Choose a reason for hiding this comment

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

Aún te faltan varias interacciones. Vas por buen camino. Venga que tu puedes sacar un 100% de verde y más. 💪

@AriadnaNatsuki
Copy link
Author

AriadnaNatsuki commented Apr 22, 2021 via email

@AriadnaNatsuki
Copy link
Author

AriadnaNatsuki commented Apr 22, 2021 via email

@AriadnaNatsuki
Copy link
Author

AriadnaNatsuki commented Apr 22, 2021 via email

@AriadnaNatsuki
Copy link
Author

AriadnaNatsuki commented Apr 22, 2021 via email

@Kunry
Copy link

Kunry commented Apr 22, 2021

Como las que faltan son bonus, voy a pelearme un poco con el lab de css de spotify primero. CSS me trae loca, en el mal sentido...

________________________________ De: Gabriel Cebrián Lucas @.> Enviado: miércoles, 21 de abril de 2021 20:08 Para: ironhack-labs/lab-javascript-functions-and-arrays @.> Cc: Elizabeth Colastra @.>; Author @.> Asunto: Re: [ironhack-labs/lab-javascript-functions-and-arrays] [WEB-MAD-PT-APRIL-2021] Elizabeth Colastra (#2342) @Kunry commented on this pull request. Aún te faltan varias interacciones. Vas por buen camino. Venga que tu puedes sacar un 100% de verde y más. 💪 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#2342 (review)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AONEDKMYFOIKFOH2GQGIF63TJ4IDFANCNFSM43IDP2IQ. [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

Solo existen 3 bonus, que son las interacciones 4.1, 8 y 8.1
Las interacciones 5, 6 y 7 que te faltan son obligatorias.

PD: Se puede contestar dentro de los comentarios que te he escrito. Te contesto en ellos.

@AriadnaNatsuki
Copy link
Author

AriadnaNatsuki commented Apr 22, 2021 via email

@stale
Copy link

stale bot commented Jun 2, 2021

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 Jun 2, 2021
@stale
Copy link

stale bot commented Jun 5, 2021

This pull request is closed. Thank you.

@stale stale bot closed this Jun 5, 2021
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