reading-notes

this repo will contain my reading during the course .

View on GitHub

class02

Basic JavaScript Instructions

Text

Paragraphs

To create a paragraph, surround the words that make up the paragraph with an opening <p> tag and closing </p> tag

Bold & Italic: By enclosing words in the tags b and b we can make characters appear bold. i By enclosing words in the tags i and the i we can make characters appear italic.

Superscript & Subscrip

The * the sup* element is used to contain characters that should be superscript such as the suffixes of dates or mathematical concepts like raising a number to a power such as 22

The sub element is used to contain characters that should be subscript. It is commonly used with foot notes or chemical formulas such as H20. p On the 4th of September you will learn about E=MC2.</p><p>The amount of CO2 in the atmosphere grew by 2ppm in 20091.</p> On the 4th of September you will learn about E=MC2. The amount of CO2 in the atmosphere grew by 2ppm in 20091.

White Space: When the browser comes across two or more spaces next to each other, it only displays one space. Similarly if it comes across a line break, it treats that as a single space too. This is known as white space collapsing

Line Breaks & Horizontal Rules:
As you have already seen, the browser will automatically show each new paragraph or heading on a new line. But if you wanted to add a line break inside the middle of a paragraph you can use the line break tag
.

<hr /> To create a break between themes — such as a change of topic in a book or a new scene in a play — you can add a horizontal rule between sections using the <hr /> tag They also provide semantic information (e.g. where emphasis should be placed, the definition of any acronyms used, when given text is a quotation).

Abbreviations & Acronyms If abbr you use an abbreviation or an acronym, then the abbrelement can be used. A title attribute on the opening tag is used to specify the full term.

When you are referencing a piece of work such as a book, film or research paper, the cite element can be used to indicate where the citation is from

The dfn first time you explain some new terminology (perhaps an academic concept or some jargon) in a document, it is known as the defining instance of it

Author Details The address element has quite a specific use: to contain contact details for the author of the page Changes to Content

The ins element can be used to show content that has been inserted into a document, while the del element can show text that has been deleted from it.

The s element indicates something that is no longer accurate or relevant (but that should not be deleted)

Introducing CSS

The key to understanding how CSS works is to imagine that there is an invisible box around every HTML element.

Using Internal CSS

CSS Selectors: Different types of selectors allow you to target your rules at different elements.

Inheritance

Basic javascript instructions

A script will have to temporarily store the bits of information it needs to do its job. It can store this data in variables.

JavaScript DATA TYPES distinguishes between numbers, strings, and true or false values known as Booleans.

Here are six rules you must always follow when giving a variable a name:

  1. The name must begin with a letter, dollar sign ($),or an underscore (_). It must not start with a number.
  2. All variables are case sensitive, so score and Score would be different variable names, but it is bad practice to create two variables that have the same name using different cases.
  3. The name can contain letters, numbers, dollar sign ($), or an underscore (_). Note that you must not use a dash(-) or a period (.) in a variable name.
  4. Use a name that describes the kind of information that the variable stores. For example, fi rstName might be used to store a person’s first name, l astNarne for their last name, and age for their age.
  5. You cannot use keywords or reserved words. Keywords are special words that tell the interpreter to do something. For example, var is a keyword used to declare a variable. Reserved words are ones that may be used in a future version of JavaScript. ONLINE EXTRA View a full list of keywords and reserved words in JavaScript.
  6. If your variable name is made up of more than one word, use a capital letter for the first letter of every word after the first word. For example, f i rstName rather than fi rstnarne (this is referred to as camel case). You can also use an underscore between each word (you cannot use a dash).

example of JS code

JS example

Arrays

ARITHMETI C OPERATORS JavaScript contains the following mathematical operators, which you can use with numbers. You may remember some from math class.

Decisions & loops

1- Comparison and Logical operators

You can evaluate a situation by comparing one value in the script to what you expect it might be. The result wil be a boolean: true or false.

Keep in mind that you must use “==”, not “=”, when testing if two primitive values are equal.

- Logical operators

Logical operators allow you to compare the results of more than one comparison operator.

2- LOOPS

Loops are used in JavaScript to perform repeated tasks based on a condition. Conditions typically return true or false when analysed. A loop will continue running until the defined condition returns false.

The three most common types of loops are:

1- For

If you need to run code a speciific number of times , use a for loop.in a for loop , the condition is usually a counter which is used to tell how many times the loop should run INITIALIZATION , CONDITION, UPDATE

for loop explain:

2- while

If you do not know how many times the code should run , you can use a while loop. Here the condition can be something other than counter, and the code will continue to loop foras long as the condition is true using while loops while loop explain

3- do while

The do…while loop is very similar to the while loop, but hasone key difference: itwill always run the statements inside the curly braces at least once, even if the condition evaluates to false.

do while loop explain

Learn more about loops

If statements: