-
Notifications
You must be signed in to change notification settings - Fork 17
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
Implemented assignments #54
base: main
Are you sure you want to change the base?
Conversation
d856718
to
7a94968
Compare
export const getAnonName = (firstName) => { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
if (!firstName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution. Great approach handling the rejection (fail-first) first.
} | ||
const is2Digit = (number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done with your solution. It works but we can improve it bit.
Firstly, nice that we are using a function is2Digit
to determine whether a given number is a two-digit number.
Our current function uses a while
loop to repeatedly divide the number by 10 until it becomes 0. Using while
loop here makes our solution a bit inefficient (time-wise). This iterative process is computationally expensive for larger numbers, even though the problem only requires checking for two digits.
Note: Two digit number is a number that is equal to or greater than 10 and also a number that is equal to or less than 99 (e.g 10, 11, 12, ..., 97, 98, 99). Therefore, we can use an if
statement to check this.
Alternaive approach:
const is2Digit = (number) => {
return number >= 10 && number <= 99;
};
In this solution, we are not checking edge cases such as when the number is a negative number.
const dice = [1, 2, 3, 4, 5]; | ||
return rollDie(1); | ||
const diceRolls = dice.map(() => rollDie()); | ||
return Promise.all(diceRolls); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job.
@@ -17,13 +17,24 @@ import { rollDie } from '../../helpers/pokerDiceRoller.js'; | |||
export function rollDice() { | |||
const results = []; | |||
|
|||
// TODO: expand the chain to include five dice | |||
return rollDie(1) | |||
.then((value) => { | |||
results.push(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, this works as expected.
But if you noticed, we are repeating these two codes from line 22 to 39:
results.push(value);
return rollDie(4);
We can prevent this with a Software engineering principle called "DRY Principle" by putting both as a function and use the function when needed. "Don't Repeat Yourself" (DRY) is a software development principle that helps us to avoid duplicating code. If you aren't aware of it, you can Google Search.
### 3-UsingAPIs - Week1 | ||
|
||
| Exercise | Passed | Failed | ESLint | | ||
|-----------------------|--------|--------|--------| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samira313 Great job completing week 1 assignment. Kudos!!! I will Approve it now.
Dear Damilare David Oyediran,
I appreciate your valuable feedback on my assignment. Your suggestion
regarding the DRY (Don’t Repeat Yourself) principle was really helpful, and
I understand the importance of avoiding redundant code.
I will make the necessary changes and optimize my code accordingly. Thank
you for your time and guidance—I truly appreciate your support in helping
me improve my coding practices.
Best regards,
Samira Ahmadi
…On Sun, 2 Feb 2025 at 23:41, Damilare David Oyediran < ***@***.***> wrote:
***@***.**** approved this pull request.
—
Reply to this email directly, view it on GitHub
<#54 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BKWT54OTCRPFIKE7IMZKLLD2N2NIVAVCNFSM6AAAAABWCZ573GVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKOBYGY3DCMJXGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
You are welcome. I look forward to the changes. |
Thanks for replying.
I have implemented the requested changes and submitted them for review.
I look forward to your feedback.
…On Mon, 3 Feb 2025 at 22:37, Damilare David Oyediran < ***@***.***> wrote:
You are welcome. I look forward to the changes.
—
Reply to this email directly, view it on GitHub
<#54 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BKWT54MFBY4U32WZG3XJLTD2N7OSXAVCNFSM6AAAAABWCZ573GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZSGEZTCNJUGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
No description provided.