Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

BCN - Cristina and Dominik#149

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
dlasch089 wants to merge1 commit intoironhack-labs:masterfromdlasch089:master

Conversation

dlasch089
Copy link

@dlasch089dlasch089 commentedOct 17, 2017
edited by tawebbcn
Loading

@tawebbcn
Copy link
Contributor

Very good job!

Tips:

  • you can use!newList.includes(el) instead ofnewList.includes(el) === false
  • Make sure you check if array.length is larger then 0.
function averageNumbers(array) {  var total = 0;  if (array.length > 0) {    array.forEach(function(el) {      total += el;    });    return total / array.length;  }  return 0;}var numbers2 = [2, 6, 9, 10, 7, 4, 1, 9];var average = averageNumbers(numbers2);console.log("the average of the array is: ", average);
  • Use can use includes here.
var words = [  "machine",  "subset",  "trouble",  "starting",  "matter",  "eating",  "truth",  "disobedience",];// Finding Elementsfunction doesWordExist(wordsArray, word) {  var exist = false;  for (var ix = 0; ix < words.length; ix++) {    if (words[ix] === word) {      exist = true;      break;    }  }  return exist;}var hasMatter = doesWordExist(words, "subset");console.log("The word exists: ", hasMatter);var hasDog = doesWordExist(words, "dog");console.log("The word exists: ", hasDog);

Updated code:

// Finding Elementsfunction doesWordExistUpdated(wordsArray, word) {  if (wordsArray.includes(word)) {    return true;  } else {    return false;  }}var hasMatter = doesWordExistUpdated(words, "subset");console.log("The word exists: ", hasMatter);var hasDog = doesWordExistUpdated(words, "dog");console.log("The word exists: ", hasDog);

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@dlasch089@tawebbcn

[8]ページ先頭

©2009-2025 Movatter.jp