Hi guys! After receiving so many requests, here is a crash course on JavaScript.
JavaScript is the most popular programming language in the world and it is easy to
learn. It is used to create interactive and dynamic web pages.
Variables
In JavaScript, variables are used to store data. They can be created using the var,
let, or const keywords.
var: used to declare a variable with function scope or global scope.
let: used to declare a block-scoped variable.
const: used to declare a constant variable.
Data Types
JavaScript has several data types:
Primitive Data Types: number, string, boolean, null, undefined.
Non-primitive Data Types: object.
Operators
JavaScript has several operators:
Arithmetic Operators: +, -, *, /, %.
Assignment Operators: =, +=, -=, *=, /=, %=.
Increment and Decrement Operators: ++, --.
Comparison Operators: ==, ===, !=, !==, <, >, <=, >=.
Logical Operators: &&, ||, !.
Functions
A JavaScript function is a block of code designed to perform a specific task. They
can be created using the function keyword.
function functionName() { // code to be executed}
Function Parameters
Function parameters are used to pass values to a function when it is called. They
are defined when declaring the function.
function functionName(parameter1, parameter2) { // code to be executed}
Statements
JavaScript statements are used to control the flow of execution in a program. They
include if-else statements and loops.
If-Else Statements
If-else statements are used to execute a block of code based on a specific
condition.
if (condition) { // code to be executed if condition is true} else { // code to
be executed if condition is false}
For Loop
A for loop is used to repeatedly execute a block of code for a specific number of
times.
for (initialization; condition; increment/decrement) { // code to be executed}
Demo okay, so 1, 3, 9, 10. Okay, okay. I should bring each and every apple from
this side to the other side. Task, okay, okay, start. Okay, okay, first the count =
1, 2, 3, 4. Okay, less than or equal to 5. Correct, true. Next, next, start + 1.
Certainly false. Okay, okay, counter already 1, second one, third one. Okay, for
count, okay, correct 1, 2, 3, 4, 5. Condition, count = count + step 1. Step 1,
count = 1, count <= 5, 1 <= true, count = count + 1. Step 2, count = 2, count <= 5,
2 <= 5, count or 1, 2, 3. Okay, okay, so again, okay, okay, next. So okay, print
all the numbers from 1 to 10 using a for loop. 1, 2, 3, 4. Count, count, 2, 3, 4.
Okay, okay, so instead count = count. Okay, okay, so next number, reverse number.