Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

My Solution- it works but its not perfect

So i completed my solution before watching the video. It answers all the questions from the assignment. However, it's not the same. Curious as to how i can fix it or make smaller? Seems like it could also be longer than needed but not sure how to maybe shrink it? Thanks in advance!

https://teamtreehouse.com/workspaces/35613112#

Steven Parker
Steven Parker
229,732 Points

You can't share a direct URL to your workspace, it's temporary and only exists while you are using it.

But you can use the snapshot function in the workspace and provide the link to that.

Ahh thank you! This is the proper snapshot of my work lol https://w.trhou.se/2d3816umzm

1 Answer

Steven Parker
Steven Parker
229,732 Points

The instructions say to convert the inputs "from a string to a floating point number", but this code converts to an integer instead. So instead of "parseInt" you could use "parseFloat". This will allow it to handle inputs like "2.5".

You could do the conversions just once and store the numbers in variables, then you would not need to keep converting over and over for each calcualtion. This would be an application of the "DRY" principle (Don't Repeat Yourself).

Good first try, and with these two fixes it should be pretty close to perfect. :+1:

Ahh! Thank you!