Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
216,096 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
216,096 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!