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

BER-FTWD-Phillip #1543

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

BER-FTWD-Phillip #1543

wants to merge 1 commit into from

Conversation

phpaul89
Copy link

except Bonus Iteration 8 & 8.1

Copy link

@fenrew fenrew left a comment

Choose a reason for hiding this comment

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

A really really well done lab!:) I decided to be a bit more strict in my comments as you are very advanced in javascript already, but this is soooo nicely coded!

@@ -1,19 +1,103 @@
// Iteration #1: Find the maximum

function maxOfTwoNumbers(a,b){
if(a > b){
Copy link

Choose a reason for hiding this comment

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

You can rather write: if(a >= b) {return a}
This way you dont need to make the else statement:)

// Iteration #2: Find longest word
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];

function findLongestWord(arr) {
if(arr.length == 0){
return null;
Copy link

Choose a reason for hiding this comment

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

Since you return here, you dont need to have an else statement as you are returning here (meaning it will go out of the function and not execute the rest of the function anyways)

let sum2 = 0;

for(let j=0; j < mixArr.length; j++) {
if(typeof mixArr[j] == "number") {
Copy link

Choose a reason for hiding this comment

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

You can actually make and or statement here:
typeof mixArr[j] == "number" || typeof mixArr[j] == "boolean"

since a number + a boolean results in: 5 + true === 6, and 5 + false === 5

return null;
}

return sumNumbers(numArr)/numArr.length;
Copy link

Choose a reason for hiding this comment

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

Nice to see you are re-using your functions!

return null;
}

return Array.from(new Set(wordsArr));
Copy link

Choose a reason for hiding this comment

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

Clever;)

return null;
}

if(wordsArr.find(word => word == searchterm) !== undefined){
Copy link

Choose a reason for hiding this comment

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

I THINK you can instead write:
return wordsArr.find(word => word == searchterm) !== undefined

this will either return true or false depending if the condition is met or not

@phpaul89
Copy link
Author

phpaul89 commented Mar 25, 2020 via email

@stale
Copy link

stale bot commented Apr 24, 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 Apr 24, 2020
@stale
Copy link

stale bot commented Apr 26, 2020

This pull request is closed. Thank you.

@stale stale bot closed this Apr 26, 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.