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 JavaScript Basics (Retired) Creating Reusable Code with Functions Introducing Functions

3 Answers

Matthew Long
Matthew Long
28,407 Points

There are a few differences in the code. First thing I notice is you're calling a function that doesn't exist. The function you made is alertrandom() but the function you call is alertRandom(). Math isn't capital either, and you're missing a semicolon, lastly there is a plus sign where there should be an equal sign.

You likely would have found these errors in your console if you check there!

Steven Parker
Steven Parker
231,060 Points

Missing a semicolon? Where?

Matthew Long
Matthew Long
28,407 Points

Sorry Steven I only answered because I saw your answer only fixed one of his issues, but you updated your answer and he's in good shape now! :)

Steven Parker
Steven Parker
231,060 Points

In random.js on line 1 you define "alertrandom" (with little "r") but on line 5 you call "alertRandom" (capital "R"). Then on line 2 there is a plus sign ("+") following the variable name where there should be an assignment operator ("="), and "Math" is spelled correctly one time but the next time it is "math" (little "m") instead.

Also, while not a syntax error, in index.html the script tag is inside a div element, but normally it would be the last thing in the body.