View on GitHub

reading-notes

HTML

Lists

tag meaning
<ol> ordered list
<ul> unordered list
<dl> definition list
<dt> definition term
<dd> definition

CSS

Boxes

box dimensions

By default a box is sized just big enough to hold its contents. To set an dimensions for a box you can use the height and width properties.

Limmiting width and height


p { 
    min-height: 10px;
    max-height: 30px;
    min-width: 450px;
    max-width: 650px; }

overflow

The overflow property tells the browser what to do if the content contained within a box is larger than the box itself


p.one { 
    overflow: hidden;}
p.two { 
    overflow: scroll;}

Border, margin and Padding

Note : If you specify a width for a box, then the borders, margin, and padding are added to its width and height

border-width

The border-width property is used to control the width of a border. The value of this property can be used thin, medium or thick

border-style

style display
solid a single solid line
dotted a series of square dots
dashed a series of short lines
double two solid lines
groove appears to be carved into the page
ridge appears to stick out from the page
inset appears embedded into the page
outset looks like it is coming out of the screen
hidden/none no border is shown

JavaScript

Decisions and Loops

Switch statment

A switch statement starts with a variable called the switch value. Each case indicates a possible value for this variable and the code that should run if the variable matches that value

Note: At the end of each case is the break keyword. It tells the JavaScript interpreter that it has finished with this switch statement and to proceed to run any subsequent code that appears after it.

if vs switch statments

if :

switch :

type correction

when JavaScript convert data types behind the scenes to complete an operation

weak typing

the data type for a value can change. Some other languages require that you specify what data type each variable will be. They are said to use strong typing

Note : NaN is a value that is counted as a number. You may see it when a number is expected, but is not returned, e.g .. (‘ten’ /2) results in NaN.

loops

loops check a condition. if it returns true, a code block will run. then the condition will be checked again if it still return true, the code block will run again. it repeats until the condition returns false.

types of loops

Nots :

Examples of using for loops :


var scores= [24. 32, 17];             //Array of scores
var arraylength scores.length;       // Items in array
var roundNumber = O;                //Current round 
var msg '';                        //Message 
var i ;                           // Counter 
//Loop through the items in the array 
for (i = O; i < arraylength; i++) { 
//Arrays are zero based (so 0 is round 1) 
//Add 1 to the current round 
roundNumber = (i + l); 
// Write the current round to message 
msg += 'Round ' + roundNumber + ' : '; 
//Get the score from the scores array 
msg += scores[i] + '<br / >' ; 
}
document.getElementByid( 'answer') .innerHTML msg; 

Example of using do while loops


var i = l ; //Set counter to 1 
var msg = ' ' ;  // Message
 
//Store 5 times table in a variable 
do { 
msg += i + ' x 5 = ' + (i * 5) + '<br I>' ;s i++; 
 } wh il e ( i < 1) ; 
//Note how this is already 1 and it still runs 
document.getEl ementByid( ' answer') . innerHTML = msg;