-
Notifications
You must be signed in to change notification settings - Fork 8
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
base: master
Are you sure you want to change the base?
Conversation
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! 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(); |
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.
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/.
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.
Got it! Will never do it again😄 Thanks!
return allNames; | ||
const namesLimited = allNames.slice(0,limit); | ||
|
||
return limit ? namesLimited : allNames; |
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.
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);
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.
Oh yes, you are totally right! 🙏 Thanks!
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