Posts

Showing posts from 2021

JavaScript syntax

  JavaScript syntax // How to create variables: var  x; let  y; // How to use variables: x =  5 ; y =  6 ; let  z = x + y; The two most important syntax rules for fixed values are: 1.  Numbers  are written with or without decimals: 10.50 1001 2. Strings are text, written within double or single quotes: example: "John Doe" 'John Doe' JavaScript Variables In a programming language,  variables  are used to  store  data values. JavaScript uses the keywords  var ,  let  and  const  to  declare  variables. An  equal sign  is used to  assign values  to variables. In this example, x is defined as a variable. Then, x is assigned (given) the value 6: example : let  x; x =  6 ; JavaScript Operators JavaScript uses arithmetic operators ( + - * / ) to compute values: example : JavaScript uses an assignment operator ( = ) to assign values to variables: example : let  x, y;...

JavaScript Statements

JavaScript Statements JavaScript statements are composed of: Values, Operators, Expressions, Keywords, and Comments. This statement tells the browser to write "Hello Dolly." inside an HTML element with id="demo":   let  x, y, z;     // Statement 1 x =  5 ;           // Statement 2 y =  6 ;           // Statement 3 z = x + y;       // Statement 4 Semicolons separate JavaScript statements. Add a semicolon at the end of each executable statement: let  a, b, c;   // Declare 3 variables a =  5 ;         // Assign the value 5 to a b =  6 ;         // Assign the value 6 to b c = a + b;     // Assign the sum of a and b to c