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

What I am I missing? (Code Check/Advice)

const Materials_Weight = 0.65; var UserWeight= prompt("What is your character's maximum inventory weight?"); parseInt(UserWeight,10); function convert (UserWeight){ var result= (UserWeight/Materials_Weight); parseFloat(result,10); return(result); } var Production= "You will produce" + result + 'beers';{} alert(Production);

1 Answer

Steven Parker
Steven Parker
231,153 Points

The function "convert" is defined but never called. Also the variable "result" that is created inside the function is not available to the code outside the function.

A quick fix would be to replace the outside reference to "result" by calling the function:

var Production = "You will produce " + convert(UserWeight) + " beers";

And the braces {} before the "alert" don't do anything and can be removed.