Javascript Lessons

01. Strings

Strings can be written with double or single quotes. You have used both in previous demos.


02. Statements

A JavaScript program is a list of statements to be executed by a computer.

  1. Declare 3 variables
  2. Assign the value 5 to x
  3. Assign the value 6 to y
  4. Assign the sum of x + y
  5. Document the statement by finding the div ID demo_01 and write the statement inside the HTML file.
  6. Finally, you document where the answer should show up, we are using demo_numbers for each example.


03. Variables

In this example, we declare the variables as words:

  1. Declare the variables price1, price2, and total
  2. Assign the value of 5 to price1
  3. Assign the value of 6 to price2
  4. Assign the sum of price1 + price2 to total
  5. Finally you document where the answer should show up, we are using demo_numbers for each example


04. Operators

The assignment operator (=) assigns a value to a variable. Other operators include signs such as, equal, plus, subtraction, multiplication, division, percentage and combinations of these signs.

  1. Assign the value 5 to x
  2. Assign the value 2 to y
  3. Assign the value x+y to z
  4. Finally, you document where the answer should show up, we are using demo_numbers for each example


05. Data Types

JavaScript evaluates expressions from left to right. Different sequences can produce different results.