Java Script

Known as a

"Arithmatic"

"Assignment"

"Comarison"

"Logical"

operators

Basic Operators

A declaration of   let  declares a  set of Variables that can be altered using the arithmetic operator.

A declaration of   const  declares a set of Variables that should not be altered using the arithmetic operator.

 

   Arithmatic operators include Addition + , Subtration - , Multiplication *  and Division / .

const  now  =  2021;

const  ageJonas = now - 1980;

const  ageSarah = now - 2012;

 To view results a log must be added to the console.

 console.log (ageJonas,ageSarah);

 The debug console should output 41  9    

With both ages now established within a "constant" we can now accurately establish other values via Arithmatic operators.

console.log (ageJonas * 2, ageJonas / 10, 2 ** 3);

2 ** 3 means 2 to the power of 3 = 2 * 2 * 2

 The debug console should output 82  4.1 8   

Using the  operator it is possible to join strings.

const  firstName  =  'Jonas';

const  lastName = 'Flanders';

console.log(firstName + ' ' + lastName);

 The debug console should output Jonas Flanders   

Assignment operators = ,  +=, *=, ++, - -.

let x = 10 + 5;  // 15 = x

x += 10;  // 15 = x + 10 = 25

x *= 4;   // 25 = x * 4 = 100

x ++ 10;  // 100 = x + 1 = 101

x -- 10;  // 100 = x - 1 = 99

console.log(x);

 The debug console should output 15   then change to 25 then change to 100 then change to 101 then change to 99

Comparison operators > ,  <, >=, <=.

console.log(ageJonas > ageSarah);  = true

 The debug console should output true. This is because

Jonas age is 41and is grater   than Sarahs age of 9.