Skip to content

feat: All iterations for lab functions and arrays js #3848

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 1 commit into
base: master
Choose a base branch
from

Conversation

dragbrakezero
Copy link

van todas la iteraciones hechas sin los bonus como nos indicaron :)




// Iteration #3: Calculate the sum
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];

function sumNumbers() {}
function sumNumbers(numbers) {

Choose a reason for hiding this comment

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

Suggested change
function sumNumbers(numbers) {
function sum(numbers) {

Para que no te falle, el nombre de las funciones tiene que ser el que te venia por defecto si no falla los test de jasmine jejeje

Choose a reason for hiding this comment

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

ahora mismo el codigo que tienes implementado solo suma numeros, es decir si te llega un string, o un array, o un objeto, o un booleano los intentas sumar todos, y eso no deberia ser asi, tienes que especificarlos un poco, te pongo como lo haria yo vale? y me dices cualquier cosa y lo vemos vale??




// Iteration #3: Calculate the sum
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];

function sumNumbers() {}
function sumNumbers(numbers) {
if (numbers.length === 0) {

Choose a reason for hiding this comment

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

Suggested change
if (numbers.length === 0) {
function sum(numbers) {
if (numbers.length === 0) {
return 0;
}
let sum = 0;
for (let i = 0; i < numbers.length; i++) {
if (typeof numbers[i] === "string") {
sum += numbers[i].length;
} else if (typeof numbers[i] === "number" || typeof numbers[i] === "boolean") {
sum += numbers[i];
} else if (typeof numbers[i] === "object") {
throw new Error("Unsupported data type sir or ma'am");
}
}
return sum;
}

Choose a reason for hiding this comment

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

Esto que te he puesto nada me he equivocado, seria para la funcion sum, no para sumNumbers, para sumNumbers estaba genial, pero si lo piensas bien, sum y sumNumbers son iguales, solo que sum tiene vitaminas jejeje

sum += numbers[i];
}

const average = sum/ numbers.length;

Choose a reason for hiding this comment

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

Suggested change
const average = sum/ numbers.length;
const average = sum / numbers.length;

soy un pijo....


// Bonus - Iteration #4.1
function avg() {}
//function avg() {}

Choose a reason for hiding this comment

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

Suggested change
//function avg() {}
function avg() {}

No te hace falta comentarlo, asi uno de los test no te falla jejeje

@CrisArranz
Copy link

Esta genial! mirate los comentarios pero vamos genial!!

@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