JavaScript Methods Worksheet

Question 1

How is a method different from a regular function in JavaScript?

a method is a function inside of an object and is used to make changes to only the values of an object

Question 2

Why would we want to add methods to an object?

Firstly it makes the code cleaner as you wont have a ton of functions just sitting somewhere, they will be part of the object Secondly is we still want to be able to run functions on the object

Question 3

How can we access the property of an object from inside the body of a method of that object?

dot notation ex "console.log(object.value)"

Coding Problems

Coding Problems - See the 'script' tag below this h3 tag. You will have to write some JavaScript code in it.

Always test your work! Check the console log to make sure there are no errors.