JAVASCRIPT: THE DO'S JavaScript is a language for developers, and it is a must-learn. This Language allows you to implement complex features on web pages. It entails many features that you must practice and learn constantly. When learning Javascript, there are rules you must apply:

  1. JavaScript is case sensitive: Case sensitivity is a crucial factor in javascript that applies to keywords, variables, function names, and other identifiers written with a consistent capitalization of letters. Such as, if you have a variable named cat, and while printing the value of this variable, you write “Cat” instead of “cat” the result will be an error. Be aware of the fact that javascript is case-sensitive for your code to work correctly.

  2. Statements should end in a semicolon (;) Example: let a, b, c; // Statement 1 a = 4; //Statement 2 b = 5; // Statement 3 c = a + b; // Statement 4

  3. Variables: Variables give the name to a value, and we use variables in javascript so that we can always recall and reuse a value. You must define a variable before use.

Declaring a variable using let and const: We use the “let” and “const” keywords to declare a variable.

Let is a keyword used to declare a block-scoped variable. Example; let year= 1995; In other words, you're storing the number 1995 in the variable called year. Think of this as a container and, the name of the container is called
“year”. What you're storing in it is 1995. Anytime you need the number “1995” you can always recall the variable “year” also, you can always change the value of “year”.

Example: let year=1995; year =1996; // Value changed from 1995 to 1996. alert(year); When the value is changed, the old data is removed from the variable.

const – which is an abbreviated version of constant, works just like let keyword although you cannot change the value. Example: const numBalls=5; numBalls= 20; //error

const numBalls= 5; numBalls = numBalls + 1; //error

This is not allowed using the const keyword.

  1. Strings: Strings have to be enclosed in quotation marks, either single or double. E.g let name = “Jessica Jones”; // string in double quotation marks. let name ='Jessica Jones'; // string in single quotation marks.

  2. Operator Precedence If an expression has more than one operator, there is an order to how it will be executed. It is defined by the precedence, in other words, the default priority order of operators. For Instance, multiplication has higher precedence than addition. The expression (1+2)3 =7 not (1+2)3 =6. You can always check out the precedence table for more information.

  3. Increment (++) and Decrement (—) Operators The increment and decrement operator is used to increase or decrease the value by one(1). Example:

    let numCats = 9; numCats=-1; or numCats—; // decreases the number of cats by 1 numCats= 8;

    let numCats= 8; numCats=+1; or numCats++; // increases the number of cats by 1 numCats =9;

  4. To make or enter comments in the script, use “//” to start a single-line comment or combining {/* and */} to enclose a multi-line comment. Example:

One-line comment // alert (“hello”); // This comment occupies a line of it's own

Multi-line comment /* i am a comment */ . This comment starts with a forward slash and asterisk and ends with an asterisk and a forward slash

There are so many other rules we need to apply to the basic syntax of JavaScript. You can always do a little more research if you still have a lot of unanswered questions. Always remember that there are so many resources that will be of help.