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

Paris - Samuel & Poeli #758

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
Closed

Conversation

petitkriket
Copy link


return avg / array.length
}

Choose a reason for hiding this comment

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

You could have done this part as well with a for loop, like this:

function averageWordLength(array) {
  if (array.length === 0) {
    return undefined;
  }
  var sumLetters = 0;
  for (var i = 0; i < array.length; i++) {
    sumLetters += array[i].length;
  }
  return sumLetters / array.length;
}



return newArray;
}

Choose a reason for hiding this comment

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

It was a good beginning. With a for loop, you would probably have done it till the end.
Here is the solution to do it with a for loop. Don't be afraid of it! ;)

function uniquifyArray(array) {
  var newArray = [];
  if (array.length === 0) {
    return undefined;
  }
  for (var i = 0; i < array.length; i++) {
    if (newArray.indexOf(array[i]) === -1) {
      newArray.push(array[i]);
    }
  }
  return newArray;
}

@ta-web-paris
Copy link

Well done! You understood the notions in the exercise. Keep going this way!

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.