Date: 1403,05,07- 2024,07,28
Stack:
- Example of Method:
pop()
,push()
- LIFO last in first out
Queue:
- Example of Method:
unshift()
,shift()
- FIFO first in first out
An algorithm is a step-by-step summary of the procedure, while on the other hand, a flowchart illustrates the steps of a program graphically.
Oval: For start and end.
Rectangle: For process.
Parallelogram: For input and output.
Rhombus: For if and conditional commands.
Example (1): Write an algorithm that receives two numbers and then adds them and finally displays them.
- Define variable A and save it in memory.
- Define variable B and save it in memory.
- Define variable sum and save it in memory.
- Get the first value from the user and store it in variable A.
- Get the second value from the user and store it in variable B.
- Do this operation:
sum = A + B
- Display the
sum
variable.
Tip
Each part of a flowchart is a part of the process of that program
if ( Condition ) {
// Code
// Code
// Code
}
=: It is used to assign a value to a variable. - let a = 20
==: It is used to show equality. - console.log(20 == 21) // False
===: It is used for equal value and data type. - console.log('20' === '20') // True
!=: The opposite of equality works. - console.log(12 != 12) // True
!==: The opposite of === works. - console.log('20' !== 20) // True
>: It means that if it was more than this amount. - console.log( 10 > 5 ) // True
<: It means that if it was less than this amount. - console.log( 10 < 5 ) // False
>=: It means that if it was more and equal than this amount. - console.log( 5 >= 9 ) // False
<=: It means that if it was less and equal than this amount. - console.log( 10 <= 11 ) // True
*: It is used to multiply. - console.log( 100 * 2 ) // 200
/: It is used to division. - console.log( 100 / 2 ) // 50
+: It is used to subtraction. - console.log( 100 - 2 ) // 98
-: It is used to adding. - console.log( 100 + 2 ) // 102