reading-notes

View project on GitHub

JavaScript

What is a script ?

A script is a series of instructions that a computer can follow to achieve a goal.

JavaScript is a text-based programming language used both on the client-side and server-side that allows you to make web pages interactive. Where HTML and CSS are languages that give structure and style to web pages, JavaScript gives web pages interactive elements that engage a user.

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

  1. The name must begin with a letter, dollar sign ($),or an underscore (_). It must not start with a number.

  2. 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.

  3. You cannot use keywords or reserved words. Keywords are special words that tell the interpreter to do something.

  4. 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.

  5. Use a name that describes the kind of information that the variable stores.

  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.

Assigning a value to a variable

var VariableName=value;

The value could be iteger, floate,list,boolean and string.

If statment

The IF statement executes one set of code if a specified condition is met (TRUE) or another set of code evaluates to FALSE.

if (condition)

{
executes this if the condition met

}

else

{

executes this if the condition did’nt met

}

prompt function

Prompt()

Allows the user to input anything>