Skip to content
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

Testing dojo solutions #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ArpadBencze
Copy link

Hey Andrew!

Thanks for the great hands-on session, I really loved it! 🙂
I created this pull request so if you have some time to check it out maybe and give some suggestions how to improve my code that would super cool and more than welcome!

Have a nice day!

Arpi

Copy link
Owner

@drewmoore drewmoore left a comment

Choose a reason for hiding this comment

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

Nice! I'm glad you enjoyed the lesson.

@@ -22,8 +22,9 @@ const localisePrice = (price, locale) => {
* Implement me!
* Hint: .toFixed() might help...
*/
price = price.toFixed(2).toString();
Copy link
Owner

Choose a reason for hiding this comment

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

This works, but I would generally advise assigning this to a new variable. Reassigning function arguments can be problematic. It changes a function's arguments property. Here's an article that explains this concept: https://spin.atomicobject.com/2011/04/10/javascript-don-t-reassign-your-function-arguments/.

Copy link
Author

Choose a reason for hiding this comment

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

Got it! Will never do it again😄 Thanks!

return allNames;
const namesLimited = allNames.slice(0,limit);

return limit ? namesLimited : allNames;
Copy link
Owner

Choose a reason for hiding this comment

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

Here, I would advise only performing the .slice() operation if there is a limit. If there is not a need for it, then it is more optimal to return allNames. For example, you could do:

return !limit ? allNames : allNames.slice(0,limit);

Copy link
Author

Choose a reason for hiding this comment

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

Oh yes, you are totally right! 🙏 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants