# Basic Algorithm with Typescript (Part 1)

*basic programming for zero experience people*

**What is Algorithm ?**

In mathematics and computer science field, algorithm is a finite list of instructions given to a computer or we can describe as a finite sequence of computer implementable instructions.

In simple explanation we can say algorithm is list of step to do something / to make something (output).

Every daily basis activities of your life are using the concept of algorithm, for example:

- How you go to school from your home ?

So, from the picture above we can write a code like this:

`function goToSchool() {`

wakeUp();

bath();

cook();

eat();

hopInSchoolBus();

arriveAndLearn();

}

# Basic Logic Syntax in Programming you need to know:

- Operator
- Conditional
- Iteration

## What is Operator ?

An Operator is a symbol / character that determine what action should be performed. There are several operator category that necessary for you:

**Arithmetic Operators**

Arithmetic Operators are operators that perform mathematic calculations. For example, assume we have 2 variables that contain number value:

let a = 5;

let b = 10;// addition

console.log(a + b)// 15console.log(a - b) // -// substraction5//console.log(a * b) //multiplication50//console.log(a / b) //division0.5//console.log(a % b) //modulus5a++;// increment

console.log(a) //6b--;// decrement

console.log(b) //9

💡 There are 2 categories of increment / decrement operators. **Pre-increment** means increment of the variable then save the expression value, on the other hand **post-increment** means increment of the variable then remember the original value before the increment process.

**Pre increment:**

let angka = 10;

let res = ++angka;console.log(res); //11

**Post increment:**

let angka = 10;

let res = angka++;console.log(res) //10

2. **Relational Operators**

Relational Operators are operators that evaluate what kind of relationships between 2 value. For example, assume we have 2 variables that contain number value same as number 1:

let a = 5;

let b = 10;// greater than

console.log(a > b)// falseconsole.log(a < b) //// lesser thantrue//console.log(a >= b) //greater than or equal tofalse//console.log(a <= b) //lesser than or equal totrue//console.log(a == b) //equalityfalseconsole.log(a != b) //// not equaltrue

3. **Logical Operators**

Logical operators are used to combine two or more relational operators. Logical operator will return a boolean value type.

let a = 5;

let b = 10;//console.log(a > 5 && b > 10) //ANDfalse//console.log(a > 5 || b >= 10)OR// true//console.log(!(a > 5)) //NOTtrue

4.** Assignment Operators**

Assignment operators are used for mathematical calculation and pass the result into a new variable.

let a = 5;

let b = 10;

let c = 0;//simple assignment

c = a + b //15//c += aadd assignment// 5//c -= a //substract assignment-5//c *= a //multiply assignment0//c /= a //division assignmentinfinite

5. **Miscellaneous Operators**

**Negation operator**

let x = 4;

let y = -x;console.log(y) //-4

**String concat operator**

String concat operator used to combined 2 or more string variable

let message = "hello";

let text = " world";console.log(message + text + " again !");

//"hello world again !"

**Typeof operator**

Typeof operator is used to return the data type of a variable

`let num = 5;`

console.log(typeof num) // *number*

This is the end of part 1, this article is more focusing on the concept of operators and how you apply it to your code. For the next part, I will write about conditional statement.