Skip to content

Simon Ertel [WDFT June 2020 Berlin] #1677

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

Conversation

SiEr0212
Copy link

@SiEr0212 SiEr0212 commented Jun 2, 2020

Simon Ertel [WDFT June 2020 Berlin]

@SiEr0212 SiEr0212 changed the title done Simon Ertel [WDFT June 2020 Berlin] Jun 3, 2020
Copy link

@timbotimber timbotimber left a comment

Choose a reason for hiding this comment

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

Some nice functions here! Happy to discuss any concepts you might not have fully grasped if you'd like though.

if (a === b) {
return a || b;
}
}

Choose a reason for hiding this comment

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

sweet. Could refactor it slightly so it's a bit shorter:

function maxOfTwoNumbers(n1, n2) {
  if (n1 > n2) {
    return n1;
  }
  return n2;
}

// return 0;
//}
let sum = 0;
for (i = 0; i < arr.length; i++) {

Choose a reason for hiding this comment

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

You need to declare i so the for loop can run.

return sum;

}

Choose a reason for hiding this comment

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

this function completes but it resolves to 18miami1truebarca200lisboa810 as it's the same as the one before. We can go through this if you'd like?

}



Choose a reason for hiding this comment

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

works when the i is defined. Just make sure to add the let on line 69

return (wordAvg / wordCount);

}

Choose a reason for hiding this comment

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

the best way to attempt this one would be something like...

  • declare a variable for the total
  • create a for loop
  • Add the length of each word within the array to the total (total += wordsArr[i].length;)
  • return the average (total / wordsarr.length)

return unique;

}

Choose a reason for hiding this comment

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

nicely done!

return false;

}

Choose a reason for hiding this comment

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

also looks good! Nice one


}


Choose a reason for hiding this comment

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

I can't make this one work as expected. We can go through it if you like? I would have probably:

  • created a variable to check for true or false
  • run a for loop to compare the words in the array to the second argument
  • stop the loop and return the check variable depending on the answer
function doesWordExist(wordsFind, word) {
  let check = true;
  for (let i = 0; i < wordsFind.length; i++) {
    if (wordsFind[i] === word) {
      check = true;
      break;
      could do this with the .include method
    }
    check = false;
  }
  return check;
}

Copy link
Author

@SiEr0212 SiEr0212 Jun 3, 2020

Choose a reason for hiding this comment

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

Hey Tim, thanks a lot for your feedback. Was really helpfull.
Yeah didn't declare the i's, thx for the hint. I wondered why it didn't work.
A lot became clearer this morning during the recap of the lab with Jan. I understood the concept of the for of loop and used it in the iterations.

@stale
Copy link

stale bot commented Jul 5, 2020

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 5, 2020
@stale
Copy link

stale bot commented Jul 7, 2020

This pull request is closed. Thank you.

@stale stale bot closed this Jul 7, 2020
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