Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed JavaScript Functions!
You have completed JavaScript Functions!
Preview
Now that you've learned the basics of functions, it's time to create and call a function.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Open the file named random.js,
located inside the js folder.
0:00
This file is already linked to index.HTML.
0:03
You'll see that the file already
has a single line of code.
0:06
You've seen this code before, in
a previous course on JavaScript numbers.
0:09
This code creates a random
number from 1 to 6, and
0:13
stores it in a variable
named randomNumber.
0:17
Functions are just about
everywhere in JavaScript.
0:21
In fact,
we've used lots of functions so far.
0:24
For instance, notice the parentheses
after Math.floor and Math.random.
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up