These are my reading notes for Code Fellows
JavaScript allows you to make web pages more interactive by accessing and modifying the content and markup used in a web page while it is being viewed in a browser
JavaScript essentially allows us to give step-by-step instructions to a browser/computer, kind of like a recipe
Allows users to interact with elements of your website, and allows your website to change depending on certain events/conditions
Common versions of JavaScript that you’ll see on websites:
All of the above rely on the ability to:
Access the content of a page
Modify the content of a page
Program rules or instructions the browser can follow
React to events triggered by the user or browser
Even if scripts might appear complicated to you now, they’re actually a simple set of instructions
Individual steps of a recipe might need to be broken down further. For example, when making spring rolls, “create peanut sauce” might have its own sub-instructions. Computers need this information
Vocabulary: The words that computers understand
Syntax How you put those words together to create instructions computers can follow
Use flowcharts for the tasks you want the computer to achieve!
Essentially 2 types of expressions:
Depended on by expressions
color = 'red';
red
) to a variable (color
)area = 5 * 10;
50
to the variable area
greeting = 'Yo' + 'Timbo';
Yo
and Timbo
) to create Yo Timbo
+
symbolCheese = 10 > 20;
false
Cheese = (10 > 20) && (2<8>);
Cheese
now becomes true
There are many arithmetic operators that you might recognize from math class, but some are doubled up (like ++
or --
). Page 76 lists some of these operators
Functions combine statements together so you don’t have to keep reusing individual functions
Helps with code organization
Calling a function means you’re telling a function to do its own task.
…statements are not run until the function is called
Functions need info to perform their tasks. These are called parameters
Return values are when a function gives you an answer when you ask for it
function userName() {
document.write('this is your username');
}
userName();
function
userName
is function nameusername();
at the end is how you call the functionYou can use parameters to have code do a task without knowing all the information up front. For example, you can have a function multiply height by width, then decide what numeric values height and width have later on