Skip to content

Navigation Menu

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

[MAD PP Ángel Pérez y Esperanza Amaya] #515

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 1 commit into from

Conversation

eamayag
Copy link

@eamayag eamayag commented Aug 21, 2018

No nos ha dado tiempo al bonus.
Tenemos problemas para que reconozca los empty arrays, a pesar de que el resto de función la recorre bien.
Tampoco hemos conseguido que reconozca en algunos casos un array de un único elemento.

var longest = 0;
for (var i = 0; i < array.length; i++) {
if (array[i].length > longest) {
longest = array[i].length;
Copy link
Contributor

Choose a reason for hiding this comment

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

Os falla un pequeño detalla, en lugar de guardar la longitud del string si guardáis directamente el string y tambien tenéis el return dentro del for, si lo sacáis funcionaría.

var longest = array[0]; 
  for (var i = 1; i < array.length; i++) {
    if (array[i].length > longest.length) {
      longest = array[i];
    } 
  }
  return longest;

// Calculating a Sum

var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];

function sumArray(array) {
if (array !== "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Os falla que no estáis retornando nada cuando hacéis el reduce, os faltaría después del else: return result. y otro detalle, cuando estáis utilizando la propiedad reduce tenéis que darle un valor inicial. En total se os quedaría un código así.

  if (array !== "") {
  var result=array.reduce(function(a,b){
  return a + b;  
  },0)
} else {
  return 0;
}
return result;

// Calculate the Average

var numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];

function averageNumbers(array){
Copy link
Contributor

Choose a reason for hiding this comment

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

Os pasa lo mismo que en de arriba, también tenéis que controlar si el la variable result tiene valor para poder dividirla, porque sino os darían error.

@ta-web-mad
Copy link
Contributor

Y bueno, después de lo que os escribí arriba os faltan algunos detalles más. Si queréis que lo repasemos decírmelo y lo vemos despacio uno por uno.

#Gabriel.

@ta-web-mad ta-web-mad closed this Aug 22, 2018
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.

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