These are my reading notes for Code Fellows
<html>
is the content layer
{css}
is the presentation layer
javascript()
is the behavior layer
All three of these layers work together to make a modern functioning website
Keeping things separate means that pages will still work if certain layers don’t load/run
JavaScript allows you to add many features onto your webpage that change depending on a number of variables. This can range from what name someone enters into a form, the current time of day, or the changing cost of a good (among many others)
JavaScript is case sensitive
Calling
document.write('good afternoon');
document
= the web page.
= member operatorwrite
= adds new text/content to your page('good afternoon')
= parametersJavaScript runs wherever <script>
is added in your HTML code
A script is like a step-by-step instruction of how to tie your shoes (or any other set of instructions). Each step (e.g., “cross each lace”) is a statement.
Statements end with a ;
{
and }
are the start and end of a code block.
Each statement starts on a new line
/* Type comments to yourself using this structure */
// you can use the double forward slash for single-line comments //
Like with HTML and CSS, these will help others understand your code better (and help you when you look back at your code months down the road)
These are just like variables in math or logic, which are “calculated or computed”
Declare a variable like so:
var quantity;
var
is the variable keyword, and quantity
is the variable nameAssign a value to a variable like so:
quantity = 3;
3
is the variable value=
is the “assignment operator,” which tells our code to assign a value to that variable.1.35
'Good Afternoon!'
false
or true
(no other options)You can multiply/add/subtract/etc. variables using just their names, provided you have provided a value (see Data Types) to your variable
There are many ways to de-clutter (or simplify) creating a variable. One option is shown below:
var price = 5;
instead of
var price;
price = 5;