View on GitHub

Code Fellows reading notes

A repository for organizing notes from my learning.

Basics of HTML, CSS, and JavaScript

Text in HTML

When creating content with HTML, there are multple elements that can be used to contain text:

Semantic elements are used to add extra information to web page without affecting structure.

Introducing CSS

CSS (Cascading Style Sheet) code is used to apply style to elements, affecting their visual appearance. The cascading quality means that CSS is applied from top to bottom in a document. If multiple styles are applied to a single element, class, or ID, the last style is the one that takes precendence, from top to bottom.

There are multiple ways to apply CSS to an HTML file.

Basic JavaScript

JavaScript is used to write a series of instructions for a computer.

JavaScript stores information in variables.

Before a Variable can be assigned a value it must be declared using var or let. Variables can be both declared and assigned in the same line of code.

var ageMonths = 8;
let breed = "labrador";
//variables can be declared without values and will be undefined until assigned a value.
var name;

Variables can store numbers, strings, or booleans. At any time, the typeof operator can be used to determine the datatype of a variable.

An array is a special type of variable used to store multiple values. Arrays are indexed starting at 0.

var breeds = ['labrador', 'terrier', 'rotweiler'];
return breeds[0]; //returns 'labrador'
return breeds[1]; //returns 'terrier'
return breeds[2]; //returns 'rotweiler'

//values can be reassigned in an array
breeds[1] = 'poodle'
return breeds[1] //returns 'poodle'

Decisions and Loops

Decisions are made in JavaScript using conditional statements and comparison operators.

Comparison operators include:

Logical operators can be used in conjuction with comparison operators to create more complex conditional statements.

Conditional statements can be used to make a decision in what is called an if statement. An if statement executes its contained script if the provided conditional statement evaluates to true. This can be used to create conditional flow within script.

breed = ['labrador', 'terrier', 'rotweiler'];
dog1 = breed [0];
dog2 = bree[1];
//The following code will compare the breed of two dogs and alert the user of the result.
if (dog1 == dog2){
    alert('These dogs are the same breed!');
}else{
    alert('These dogs are not the same breed!');
}