It can be used to access from an HTML page by referencing elements
JS can be used to add or remove elements and attributes from an HTML page
Rules can be made giving a browser step by step instructions for how contents of page will work
JS can be told to reacts a certain way when there are certain actions taken by users like clicking a button or moving the cursor over an HTML element
Start by writing out your goal like tell a robot how to put on a hoodie
Break down that goal by a series of tasks like pick up hoodie, lift over head…
Create a code for each step in Javascript
understand JS language
Vocabulary - what can the computer understand?
Syntax - How can the words be put together as instructions that the computer can understand?
Programmatic Approach - understand how a computer uses this approach to problem solve
LEARN TO THINK LIKE A COMPUTER!!
REMEMBER
Sketch out tasks in a flow-chart
design the goal and design the script!
expressions result in a single value
Assign a value to a variable var color = ‘black’;
A variable might use more that one value to result in a single value var area = 2 * 400;
*expressions need operators which let creators get a single value from one or more values
Combining strings
Computing Basic Match
Comparison operators
Logical operators
Arithmetic Operators
Addition + or Subtraction -
Division / or Multiplication (*)
Increments ++ or Decrements – either adding one or subtracting one
Modulus % Dividing two values and giving back the remainder
String Operators
check example on pages 78-79
you can group a series of statements in order to perform a task
you can reuse the same functino in different parts of a script rather that repeating the same statement
functions let you store which steps are needed to perform a task
functions must be given a name so that when you call the function it knows it’s task
Steps for a funciton are in a code block {‘stepsoffunctionhere}
A BASIC FUNCTION holds the statements until the function is called for
Declaring a function
simply declare function by starting with it the function keyword followed by the function name
remember to enclose the code block using curly braces {}
the function can be called later throughout code by writing functionName follow this by parenthesis and the semi colon.
Declaring functions that need info
Give the function parameter within it;s code block which act as variabels
make note of what you the function will need to complete the task
Call the function needing info
specify the values that are to be used within within the parenthesis
there are argument values and argument variables.
functions can return information of a single value/what is left of the resul of a calculation that was called for example: var area return area