This course will be retired on January 24, 2020. We recommend "Introducing JavaScript" for up-to-date content.
Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
What you can change without breaking the code. Spoiler alert: not much.
The naming conventions of JavaScript lie on the side of camelCase, or capitalizing the first name of each new word after the first word. If you want, there are a lot of things I've written in snake_case, or underscore_case that you can go through and change. While snake_case and camelCase will both work, each language has their favorable style and because this program is written in JavaScript, you should make all the function and variable names camelCase. Later on, when you get into more advanced programming language like Python, you'll know all about writing variable and function names with snake_case :)
-
0:00
There are a lot of things in this JavaScript file that will
-
0:02
break the program if you change them.
-
0:05
However, there are a few things you should play around with.
-
0:08
The first I would change, if I were you, are the values for the mash variable.
-
0:14
Now, instead of it being mansion, apartment, shack, and
-
0:17
house, I would change it something cool, like planets or something.
-
0:22
Just keep in mind that if you make this array longer than four items, you'll want
-
0:27
to update this number down here, so it selects from all the array items.
-
0:32
Another thing you might want to try and change are the names of the variables.
-
0:37
Now, most of them are pretty descriptive, but
-
0:40
here we have answers in this function, and answers down here in this function.
-
0:46
You might want to make them different, or not, but here's an example.
-
0:50
I'll make this answers_object,
-
0:53
because this is going to help us build our answers object.
-
0:57
And then I have to look all through this function
-
1:01
to make sure I change it everywhere it appears.
-
1:05
So I have to change it down here as well.
-
1:09
And if I save it, and refresh the page, everything should still work.
-
1:15
Nice!
-
1:17
Some other small stuff that you can change,
-
1:19
if you wanted to, are the comments.
-
1:22
Remember, if you're gonna write a single-line comment, you do it at the end
-
1:27
of the line of code with two slashes, or a multiline comment with a slash and
-
1:34
a star to open and close the comment, and then you can make it as long as you want.
-
1:40
If you like organizing, you might have noticed the order of the questions
-
1:43
are not the same as I've listed them in the script file.
-
1:47
See if you can reorganize the java script to make each function organized
-
1:51
in the same way as our game.
-
1:54
If you're up for a challenge try adding another question to the form so
-
1:57
there are four or more questions in the game.
-
2:00
When you make something you think looks really good and
-
2:03
works well post it in the forum so others can see what you built.
-
2:07
Don't forget to tag me as well so I can check it out.
You need to sign up for Treehouse in order to download course files.
Sign up