HTML elements have opening tags like < h1> and closing tags like < /h1>
Text for an element goes between opening and closing tags
h1 to h6 elements signal importance. lower numbers are higher importance. only one h1 element per page
p element is used to create paragraph of text on websites
Commenting allows one to leave messages without affecting browser display and allows one to make code inactivev.
HTML5 has some elements that identify different content areas. These elements hmake your HTML easier to read and help with SEO
Above, h2 and main p elements are "Nested" inside of the main element. These should be indented two spaces farther to the right of the element they are nested in. This is calle dindentation and is used to make HTML easier to read
Images can be added to website by using the img element. img elements have opening tag and no closing tag – these types of tags are known as "self closing tags"
Attributes in HTML are special words used inside of opening tag of an element to control its behavior.
Alt attributes are displayed if image failes to load. All img elements should have alt attribute
Anchor (a) element links to another page
Link's text must be placed between opening and closing tags of anchor element
Text before anchor and after anchor will determine what gets hyperlinked
Adding target attribute with value _ blank (no space) to the anchor elements opening tab to make link open a new tab
To turn an image into a link:
Section element separates current content from future content
Adding a new section under the first section:
Adding h2 element in the second section:
Adding a third element:
ul element is unordered list:
li element is list item:
Adding new image after unordered list:
Figure element represents self contained content and will allow you to associate an image with a caption. To nest the image into a figure element:
A figure caption is used to add caption to describe images within figure element. The element is figcaption
em element is emphasize. To emphasize a word:
Adding another h3 element:
ol is ordered list element:
Add another figure element after the ordered list:
Nest another img element in the new figure element:
Add alt attribute to new img element:
Add figcaptionelement to new img element:
The strong element is used to indicate that some text is of strong importance or urgent. To make a word strong:
Add another section:
Add h2 element to new section:
Add a web form to collection information about users:
The action attribute indicates where form data should be sent:
Input element enables several ways to collect data from web form. Similar to img elements, input elements are self closing and do not need closing tags
The type attribute enables many kinds of inputs such as password field, reset button, or a control to let users select a file from their computer
Give a name attribute to assign it a value to represent the data being submitted
Placeholder texted used to give hint about what info to enter as input
the required attribute in an input element will make it so users cannot submit form without providing information that is required
The button element creates a clickable button
Something about type attribute, idk:
Radio buttons can be used for questions where you only want one answer out of multiple options
Label elements are used to help associate text for an input element with the input itself.
ID attribute is used to identify specific HTML requirements. each ID attributes value must be unique from all other ID values for the entire page.
Make new radio button
Do another thing:
And another thing:
fieldset eleemnt used to group inputs and labels together in a web form. these are "block-level" elements which means they appear on a new line
legend element acts as a caption for the content in the fieldset element. it gives users context about what htey should enter into that part of the form
add a new fieldset
do a thing:
Checkboxes are also things:
Am tired:
This one was a bit hard:
add name attribute
add another checkbox, for lazy instead of for loving
add another checkbox, this time for energetic, which I currently am not
more stuff:
make button options selected by default:
add a footer element:
add a p element (paragraph) to add some relevant info to footer:
make freecodecamp.org enclosed within anchor element pointed to site
Add head element above the body element, which contains all elements rendered to page
Add title within the head element:
set language to english
do a thing:
enable multiple languages
// is an inline comment that will tell JS to ignore remainder of text for current line
/* to open comment for a multi line comment and to close it is */
JS provices eight different data types
Variables allow computers to store and manipulate data dynamically. This is done through usin ga label to point to data rather than data itself. All 8 data types can be stored as variables; they should be thought of as similar to X and Y in math
Tell JS to create or declare a variable by putting the keyword var in front of it
Create "myName" variable:
in JS "=" is the assignment operator; we can store value in variable with it. Ex)
Another example:
Assign the value 7 to variable a:
values of multiple variables can be assigned together though using the assignment operator (=) … ex)
var myVar;
myVar = 5;
var myNum;
myNum = myVar;
Assign the contents of variable a to variable b
Variables can be "initialized" in the same line that they are created. EX)
var myVar = 0;
Define a variable of a initialized to value of 9
Strings can also be defined as a variable. A "string literal" is a series of zero or more characters enclosed in single or double quotes. EX)
var myName = "your name";
Create two new string variables: myFirstNname and myLastName and assign them values of first and last name:
Variables have initial value of undefined. doing math on it will give you NaN result, "Not a Number"
Initializae 3 variables a b and c with 5 10 and "I am a"
ALL VARIABLES AND FUCNTION NAMES ARE CASE SENSITIVE
MYVAR is not MyVar nor myvar. Possible that you have multiple distinct variables with same name but different casing
camelCase is best practice. multi word variable names have first word all lower, then first letter of each subsequent word is capitalized. EX's)
var someVariable;
var anotherVariableName;
var thisCariableNameIsSoLong;
In larger codebases var can become troublesome due to how easy it is to overwrite variable declarations. new keywords introduced to declare variables
Always use const to declare variables that you don't want to re assign
Number is data type in JS for numeric data
The "++" operator can add or increment to a variable. Ex)
The "–" operator can decrement or decrease variable by 1. Ex)
Decimals can be stored in variables as well. they are called "floating point" numbers or "floats"
The remainder operator "%" gives the remainder of the two division of two numbers. EX)
Remainder can be used to check if number is even or odd by checking the remainder of the division of the number by 2. Ex)
Note: remainder operator is sometimes called the modulus operator; this is false; it is similar, but does not work well with negative numbers
common to use assignments to modify the contents of a variable. remember that everything to the right of the equals sign is eval'd first. Ex)
Opeartors which do both a mathematical operation and assignment in one step.
+= operator will do this. ex)
-= subtracts a number rom a variable. ex)
strings must start and end with single or double quote. what happens when you need a literal quote inside of string?
to do this you can escape overarching quote with \ before each of the new quotes, to tell JS should appear inside the string as its own string. Ex)
strings can be single or double quotes, but must be consistent per string. they work the same in JS, unlike other languages. ex)
you might want to use one or the other based on if you want to use both in a string. might happen if you want to save a convo in a string and have the convo in quotes. another use for it would be saving an < a > (no spaces on that tag) tag with various attributes in quotes, all within a string. ex)
quotes are not only characters that can be escaped inside strings
two reasons to use escaping characters:
when + opeartor is used with a string value, it is called the concatenation operator. new strings can be built out of other strings by concatenating them together. ex)
+= can also be used to concatenante a string onto the end of an existing string. this can be helpful to break a long string over several lines.ex)
we can append variables to strings useing the += operator. ex)
you can find the value of a string value by writing .length after the string variable or string literal. ex)
this is a way to get a character at a specific index within a string. JS + most languages start counting at 0. this is called zero based indexing. ex)
string values are immutable – they cannot be altered once created. ex)
the only way to change myStr would be to assign it with a new string. ex)
can be used to get characters at other positions than 0
remember computers start counting at 0
subtract one from the strings length
ex) const sentence = "It was really " + "hot" + ", and we " + "laughed" + " ourselves " + "silly" + ".";
NOTE: console.log(wordBlanks) was used in order to display the value of wordBlanks which helped me figure out where the spacing issues were on the code
with array variable several pieces of data can be stored in one place
Array nesting is a thing
push makes appending data to end of an array easy
function is .push()
this can also be used to manipulate data in an array
basically it will take the last element of an array and then return it as a re assigned variable
pop function always removes the last element of an array
shift will remove the first instead of last
.shift()
unshift is like push except it adds stuff to the beginning of an array rather than to the end of one
code can be divided up into reusable parts called functions
scope is the visibility of variables
variables defined outside of a function have global scope
this means they can be seen everywhere in JS code
variables declared within function and function parameters have local scope.
these may only be true or false in their value
basically on off switches. true is on; false is off
"While loops" run when specified condition is true and stop when that condition is no longer true