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

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

Already on GitHub?Sign in to your account

Closed
phpaul89 wants to merge1 commit intoironhack-labs:masterfromphpaul89:master
Closed

Conversation

phpaul89
Copy link

except Bonus Iteration 8 & 8.1

Copy link

@fenrewfenrew 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){

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;

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") {

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;

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));

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){

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 commentedMar 25, 2020 via email

Thanks Markus,your notes are much appreciated as they help me learn more effective!Von: Markus Heldrup <notifications@github.com>Gesendet: Mittwoch, 25. März 2020 12:07An: ironhack-labs/lab-javascript-functions-and-arrays <lab-javascript-functions-and-arrays@noreply.github.com>Cc: phpaul89 <phillippaul@gmx.de>; Author <author@noreply.github.com>Betreff: Re: [ironhack-labs/lab-javascript-functions-and-arrays] BER-FTWD-Phillip (#1543)@fenrew commented on this pull request.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!
_____ In src/functions-and-arrays.js <#1543 (comment)> :
@@ -1,19 +1,103 @@
// Iteration#1: Find the maximum+function maxOfTwoNumbers(a,b){+ if(a > b){You can rather write: if(a >= b) {return a}This way you dont need to make the else statement:)
_____ In src/functions-and-arrays.js <#1543 (comment)> :
// Iteration#2: Find longest word
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];+function findLongestWord(arr) {+ if(arr.length == 0){+ return null;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)
_____ In src/functions-and-arrays.js <#1543 (comment)> :
+ let sum1 = 0;
++ for(let i=0; i < arr.length; i++){+ sum1 += arr[i];+ }++ return sum1;+}++const mixedArr = [6, 12, 'miami', 1, true, 'barca', '200', 'lisboa', 8, 10];++function sum(mixArr){+ let sum2 = 0;++ for(let j=0; j < mixArr.length; j++) {+ if(typeof mixArr[j] == "number") {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
_____ In src/functions-and-arrays.js <#1543 (comment)> :
// Iteration#4: Calculate the average
// Level 1: Array of numbers const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];+function averageNumbers (numArr){+ if(numArr.length == 0){+ return null;+ }++ return sumNumbers(numArr)/numArr.length;Nice to see you are re-using your functions!
_____ In src/functions-and-arrays.js <#1543 (comment)> :
@@ -29,9 +113,29 @@ const wordsUnique = [
'bring' ];+function uniquifyArray (wordsArr){+ if(wordsArr.length == 0){+ return null;+ }++ return Array.from(new Set(wordsArr));Clever;)
_____ In src/functions-and-arrays.js <#1543 (comment)> :
// Iteration#6: Find elements
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];+function doesWordExist (wordsArr, searchterm){+ if(wordsArr.length == 0){+ return null;+ }++ if(wordsArr.find(word => word == searchterm) !== undefined){I THINK you can instead write:return wordsArr.find(word => word == searchterm) !== undefinedthis will either return true or false depending if the condition is met or not—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub <#1543 (review)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AMUOMFLFER6LE5SUW4WPADDRJHQVRANCNFSM4LS4HS4Q> . <https://github.com/notifications/beacon/AMUOMFKAMGL2NZ5EJRPB3JTRJHQVRA5CNFSM4LS4HS42YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOC23DX5Y.gif>

@stale
Copy link

stalebot commentedApr 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.

@stalestalebot added the stale labelApr 24, 2020
@stale
Copy link

stalebot commentedApr 26, 2020

This pull request is closed. Thank you.

@stalestalebot closed thisApr 26, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fenrewfenrewfenrew left review comments

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@phpaul89@fenrew

[8]ページ先頭

©2009-2025 Movatter.jp