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

[LIS-WDFT-APR2023] Elnaz#3738

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
elnazfe wants to merge1 commit intoironhack-labs:masterfromelnazfe:master
Closed

Conversation

elnazfe
Copy link

Iteration#8 🤯🤯🤯🤯😵😵😵‍💫😵‍💫😵‍💫

Copy link

@joaopdgjoaopdg left a comment

Choose a reason for hiding this comment

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

Awesome job on the lab+bonus Elnaz!

if (mixedArr[i] === true) {
arrSum += 1;
}
arrAvg = arrSum/mixedArr.length

Choose a reason for hiding this comment

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

This line of code where you arecalculating the average should beoutside of any condition, otherwise if for some reason the array passed to the function doesn't have anyboolean that line of code will never be read, so you can actually do this math operation in thereturn:

function avg(mixedArr) {  if (mixedArr.length === 0) {    return null;  }   let arrSum = 0;    for (let i = 0; i < mixedArr.length; i++) {      if (typeof mixedArr[i] === 'number') {        arrSum += mixedArr[i];      } else if (typeof mixedArr[i] === 'string') {        arrSum += mixedArr[i].length;      } else if (typeof mixedArr[i] === 'boolean') {        if (mixedArr[i] === true) {          arrSum += 1;        }      }else{        throw new Error("Invalid data type")      }    }    return arrSum/mixedArr.length   }

Also, you're missing the last test which is to throw an error. For that you just need an else with the syntax for throwing an error inside. The jasmine test will continue to be red but your answer will be correct don't worry.

@stale
Copy link

stalebot commentedMay 21, 2023

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 labelMay 21, 2023
@stale
Copy link

stalebot commentedMay 31, 2023

This pull request is closed. Thank you.

@stalestalebot closed thisMay 31, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@joaopdgjoaopdgjoaopdg 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
@elnazfe@joaopdg

[8]ページ先頭

©2009-2025 Movatter.jp