Read07 | Programming with JavaScript
Textbook: Jon Duckett: HTML & CSS
The Magic of Scripts
- JS brings more life to a page by being able to Access Content, Modify Content, Program Rules, and React to Events
- Examples of manipulations: slideshows, forms, reloading only part of a page, filtering data
- Scripts are basically a series of instructions for the application/computer to execute
- Start by: Defining the goal, designing the script(create a flow chart!) and then code each step
Expressions + Operators
- Expressions evaluate into a result with a single value
- Operators dictate what calculations should occur when a programmer uses an expression
- Types of Operators are: Assignment (=), Arithmetic (), *String (+), Comparison (>), and Logical(&&)
Functions
- A function is a place for you to group several statements together to perform a specific task and can be reused
- Always use the keyword
functionwith a function name like “doMath” - Functions may or may not take in information, if they do, it is called a parameter
- Call functions with (), Ex: doMath() / if your function used parameters you would put those values in the () like this: doMath(1,3)
- Use
returnto get a single value from the function (usually paired with a var name) / or thereturncan be assigned to an array to get more than one value as a result