Web Development - HTML, CSS & JavaScript
55.5K subscribers
1.92K photos
5 videos
34 files
535 links
Learn to code and become a Web Developer with HTML, CSS, JavaScript , Reactjs, Wordpress, PHP, Mern & Nodejs knowledge

Managed by: @love_data
Download Telegram
๐Ÿ’ป JavaScript Learning Series: Day 5

Topic 5: Loops in JavaScript

Loops execute a block of code repeatedly while a condition is met. They save you from writing the same code over and over.

Without a loop:

console.log("Hello");
console.log("Hello");
console.log("Hello");
console.log("Hello");
console.log("Hello");


Using a loop:

for (let i = 1; i <= 5; i++) {
console.log("Hello");
}


Both produce the same output, but loops make code shorter and easier to maintain.

1. for Loop

A for loop is useful when you know how many times you want to run a block of code.

Syntax:

for (initialization; condition; update) {
// Code to execute
}


The three parts are:

โ€ข Initialization sets the starting value.

โ€ข Condition checks whether the loop should continue.

โ€ข Update changes the variable after each iteration.

Example:

for (let i = 1; i <= 5; i++) {
console.log(i);
}


Output:

1
2
3
4
5


Here, i starts at 1, increases by 1 after each iteration, and the loop ends when i <= 5 is false.

2. while Loop

A while loop runs as long as its condition is true. Itโ€™s useful when you donโ€™t know exactly how many iterations are needed.

while (condition) {
// Code to execute
}


let i = 1;

while (i <= 5) {
console.log(i);
i++;
}


The condition is checked before each iteration. Make sure the loop can eventually end, or it may run forever.

3. do...while Loop

A do...while loop runs its code at least once before checking the condition.

do {
// Code to execute
} while (condition);


do {
console.log(i);
i++;
} while (i <= 5);


Key difference:

โ€ข for is commonly used when the number of iterations is known.

โ€ข while checks the condition before running the code.

โ€ข do...while runs the code once before checking the condition.

4. for...of Loop

Use for...of to iterate over values in iterables such as arrays, strings, maps, and sets.

Example: iterating through an array:

let fruits = ["Apple", "Mango", "Banana"];

for (let fruit of fruits) {
console.log(fruit);
}


Apple
Mango
Banana


Example: iterating through a string:

let name = "JavaScript";

for (let character of name) {
console.log(character);
}


This prints each character separately.

5. for...in Loop

Use for...in to iterate over an object's enumerable property keys.

let student = {
name: "Rahul",
age: 22,
city: "Delhi"
};

for (let key in student) {
console.log(key, student[key]);
}


name Rahul
age 22
city Delhi


key is the property name, and student[key] retrieves its value. For arrays, prefer for...of or array methods.

6. Nested Loops

A nested loop is a loop inside another loop. Itโ€™s commonly used for patterns, matrices, and multidimensional arrays.

for (let i = 1; i <= 3; i++) {
for (let j = 1; j <= 3; j++) {
console.log(i, j);
}
}


1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
โค5
The inner loop completes all its iterations for each iteration of the outer loop.

7. break Statement

break immediately ends the loop.

for (let i = 1; i <= 10; i++) {
if (i === 5) {
break;
}

console.log(i);
}


```text
1
2
3
4


When i becomes 5, the loop stops.

8. continue Statement

continue skips the current iteration and moves to the next one.

javascript
for (let i = 1; i <= 5; i++) {
if (i === 3) {
continue;
}

console.log(i);
}


text
1
2
4
5


The loop skips 3 but continues running.

9. Real-World Example: Calculate Total Salary

javascript
let salaries = [25000, 30000, 35000, 40000];

let total = 0;

for (let salary of salaries) {
total += salary;
}

console.log("Total Salary:", total);


text
Total Salary: 130000


The loop visits each salary and adds it to the total.

10. Common Loop Patterns

A. Print even numbers

javascript
for (let i = 2; i <= 10; i += 2) {
console.log(i);
}


Output: 2, 4, 6, 8, 10

B. Print numbers in reverse

javascript
for (let i = 10; i >= 1; i--) {
console.log(i);
}


C. Calculate the sum of numbers

javascript
let sum = 0;

for (let i = 1; i <= 10; i++) {
sum += i;
}

console.log(sum);


text
55


D. Print a multiplication table

javascript
let number = 5;

for (let i = 1; i <= 10; i++) {
console.log(number + " x " + i + " = " + (number * i));
}


text
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
...
5 x 10 = 50`


11. Common Mistakes to Avoid

โ€ข Forgetting to update the loop variable.

โ€ข Using the wrong loop condition.

โ€ข Accidentally creating an infinite loop.

โ€ข Confusing break with continue.

โ€ข Using for...in unnecessarily for arrays.

โ€ข Making nested loops more complicated than necessary.

โ€ข Using <= instead of < when it causes an extra iteration.

12. Quick Revision: Types of Loops

๐Ÿ”น for loop โ†’ Best when the number of iterations is known.

๐Ÿ”น while loop โ†’ Repeats while a condition remains true.

๐Ÿ”น do...while loop โ†’ Runs at least once before checking the condition.

๐Ÿ”น for...of loop โ†’ Iterates over values in iterable objects.

๐Ÿ”น for...in loop โ†’ Iterates over enumerable property keys.

๐Ÿ”น Nested loop โ†’ A loop inside another loop.

๐Ÿ”น break โ†’ Terminates the loop.

๐Ÿ”น continue โ†’ Skips the current iteration.

Key Takeaways

โ€ข Loops automate repetitive tasks.

โ€ข Know when to use for, while, and do...while.

โ€ข Use for...of for iterable values and for...in for object property keys.

โ€ข Use break to stop a loop and continue to skip an iteration.

โ€ข Practice nested loops and common coding patterns.

Double Tap โค๏ธ For More
โค2
๐Ÿฏ ๐—™๐—ฅ๐—˜๐—˜ ๐—›๐˜‚๐—ฏ๐—ฆ๐—ฝ๐—ผ๐˜ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐—ณ๐—ผ๐—ฟ ๐—ฆ๐˜๐˜‚๐—ฑ๐—ฒ๐—ป๐˜๐˜€ & ๐—™๐—ฟ๐—ฒ๐˜€๐—ต๐—ฒ๐—ฟ๐˜€ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐ŸŽ“

๐Ÿ’ซHubSpot Academy offers three free online certifications that match these interests.

๐Ÿ’ซPick one free course and try it out on your next college event and the certification is free.

๐Ÿ”— ๐—Ÿ๐—ถ๐—ป๐—ธ :- ๐Ÿ‘‡

https://pdlink.in/4iM5xaQ

๐Ÿ“ฒ *Save & Share with your friends! ๐Ÿ”ฅ*
โค2
๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—š๐—ฒ๐˜ ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐——๐—ฟ๐—ฒ๐—ฎ๐—บ ๐—๐—ผ๐—ฏ ๐—œ๐—ก ๐—š๐—ผ๐—ผ๐—ด๐—น๐—ฒ๐Ÿ”ฅ

Discover *4 FREE resources* to help you prepare for a career at Google!

โœ… Improve Your Coding Skills
โœ… Strengthen Interview Preparation
โœ… Build Technical Knowledge
โœ… Prepare for Top Tech Opportunities

๐ŸŽ“Perfect for Students, Freshers & Aspiring Software Engineers!

๐Ÿ”— ๐—Ÿ๐—ถ๐—ป๐—ธ ๐Ÿ‘‡:-

https://pdlink.in/4AwRPQy

๐Ÿ“ฒ SAVE & SHARE with friends dreaming of working at Google!
โค1
๐—™๐—ฅ๐—˜๐—˜ ๐—ฉ๐—œ๐—ฅ๐—ง๐—จ๐—”๐—Ÿ ๐—œ๐—ก๐—ง๐—˜๐—ฅ๐—ก๐—ฆ๐—›๐—œ๐—ฃ๐—ฆ ๐—ช๐—œ๐—ง๐—› ๐—ง๐—ข๐—ฃ ๐—–๐—ข๐— ๐—ฃ๐—”๐—ก๐—œ๐—˜๐—ฆ! ๐ŸŽ“

๐Ÿ’ป Explore FREE Virtual Internship & Job Simulation Programs from leading companies!

โœ… Learn Industry-Relevant Skills
โœ… Work on Practical Tasks
โœ… Self-Paced Online Learning
โœ… Explore Completion Certificates
โœ… Strengthen Your Resume & LinkedIn Profile

๐ŸŽฏ Perfect for Students, Freshers & Job Seekers

๐Ÿ”— ๐—Ÿ๐—ถ๐—ป๐—ธ ๐Ÿ‘‡:-

https://pdlink.in/4t8DRlq

๐Ÿ“ฒ SAVE & SHARE with friends looking for career opportunities!
โค1
๐Ÿฐ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐—ง๐—ผ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—˜๐˜…๐—ฐ๐—ฒ๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜ ๐Ÿ“Š

๐ŸŽ“ Explore 4 FREE Excel Courses to upgrade your skills!

โœ… Excel Formulas & Functions
โœ… Pivot Tables & Charts
โœ… Data Cleaning & Analysis
โœ… Dashboards & Reporting

๐ŸŽฏ Perfect for Students, Freshers & Aspiring Data Analysts!

๐Ÿ”— ๐—Ÿ๐—ถ๐—ป๐—ธ ๐Ÿ‘‡:-

https://pdlink.in/48mO4B2

๐Ÿ“Œ SAVE & SHARE with friends who want to master Excel! ๐Ÿ”ฅ
๐Ÿ’ป JavaScript Learning Series - Day 6

Topic 6: Functions in JavaScript

Functions are one of the most important concepts in JavaScript.

A function is a reusable block of code designed to perform a specific task.

Instead of writing the same code repeatedly, you can create a function and execute it whenever needed.

For example:

โ€ข Calculate employee salaries.

โ€ข Validate user login details.

โ€ข Calculate shopping discounts.

โ€ข Process customer information.

โ€ข Perform mathematical calculations.

Let's understand functions step by step.

1. What Is a Function?

A function is a block of code that performs a particular task when called.

function greet() {
console.log("Hello, Welcome!");
}

greet();


Output:

Hello, Welcome!


Explanation:

โ€ข function โžœ Keyword used to declare a function.

โ€ข greet โžœ Function name.

โ€ข () โžœ Holds parameters, if required.

โ€ข {} โžœ Contains the function's code.

โ€ข greet() โžœ Calls or executes the function.

Important: Defining a function does not automatically execute it. You must call it.

2. Function Declaration

A function declaration defines a function using the function keyword.

Syntax:

function functionName() {
// Code to execute
}


Example:

function welcome() {
console.log("Welcome to JavaScript");
}

welcome();


Output:

Welcome to JavaScript


Function declarations can generally be called before their definition because they are hoisted.

3. Functions with Parameters

Parameters allow you to pass information into a function.

function greet(name) {
console.log("Hello " + name);
}

greet("Rahul");
greet("Priya");


Output:

Hello Rahul
Hello Priya


Here:

โ€ข name is a parameter.

โ€ข "Rahul" and "Priya" are arguments.

Difference:

Parameter โžœ Variable listed in the function definition.

Argument โžœ Actual value passed when calling the function.

4. Functions with Return Values

The return statement sends a value back from a function.

function add(a, b) {
return a + b;
}

let result = add(10, 20);

console.log(result);


Output:

30


โ€ข The function receives two values.

โ€ข It adds them.

โ€ข return sends the result back.

โ€ข The result is stored in the result variable.

Important: return also terminates the function's execution.

5. Function Expression

A function expression stores a function inside a variable.

const greet = function() {
console.log("Hello JavaScript");
};

greet();


Output:

Hello JavaScript


Unlike function declarations, function expressions assigned to variables cannot generally be called before their initialization.

6. Arrow Functions

Arrow functions provide a shorter syntax for writing functions.

They were introduced in ES6.

Traditional function:

function add(a, b) {
return a + b;
}


Arrow function:

const add = (a, b) => {
return a + b;
};

console.log(add(10, 20));


Output:

30


For a single expression, you can write:

const add = (a, b) => a + b;

console.log(add(5, 10));


Output:

15
โค4
Arrow functions are commonly used in modern JavaScript, callbacks, and array methods.

Note: Arrow functions do not have their own this binding.

7. Anonymous Functions

An anonymous function is a function without a name.

setTimeout(function() {
console.log("Hello after 2 seconds");
}, 2000);


Output after approximately 2 seconds:

Hello after 2 seconds


Anonymous functions are frequently used as callbacks.

8. Default Parameters

Default parameters provide fallback values when an argument is missing or undefined.

function greet(name = "Guest") {
console.log("Hello " + name);
}

greet("Rahul");
greet();


Output:

Hello Rahul
Hello Guest


9. Rest Parameters

Rest parameters allow a function to accept multiple arguments and collect them into an array.

function calculateTotal(...numbers) {
let total = 0;

for (let num of numbers) {
total += num;
}

return total;
}

console.log(calculateTotal(10, 20, 30, 40));


Output:

100


Here, ...numbers collects all the supplied arguments into one array.

10. Callback Functions

A callback is a function passed as an argument to another function.

function greet(name, callback) {
console.log("Hello " + name);

callback();
}

function message() {
console.log("Welcome to JavaScript");
}

greet("Rahul", message);


Output:

Hello Rahul
Welcome to JavaScript


Callbacks are widely used in:

โ€ข Event handling.

โ€ข Asynchronous programming.

โ€ข Array methods.

โ€ข API operations.

11. Immediately Invoked Function Expression (IIFE)

An IIFE is a function that executes immediately after it is defined.

(function() {
console.log("Function executed immediately");
})();


Output:

Function executed immediately


IIFEs were traditionally used to create private scopes and avoid polluting the global namespace.

12. Function Scope

Scope determines where a variable can be accessed.

JavaScript has different types of scope.

A. Global Scope

Variables declared outside functions and blocks may be accessible throughout their containing script or module environment.

let name = "Rahul";

function greet() {
console.log(name);
}


B. Function Scope

Variables declared with var inside a function are accessible within that function.

function test() {
var age = 25;
console.log(age);
}

test();


C. Block Scope

Variables declared using let and const inside a block are accessible only within that block.

if (true) {
let age = 25;
const city = "Delhi";
}

console.log(age); // ReferenceError


13. Higher-Order Functions

A higher-order function is a function that accepts another function as an argument or returns a function.

function calculate(a, b, operation) {
return operation(a, b);
}

function add(x, y) {
return x + y;
}

console.log(calculate(10, 20, add));


Higher-order functions are widely used in functional programming and array operations.

14. Real-World Example: Employee Salary Calculator
โค3
function calculateSalary(basicSalary, bonus) {
let totalSalary = basicSalary + bonus;

return totalSalary;
}

function displaySalary(name, salary) {
console.log("Employee:", name);
console.log("Total Salary:", salary);
}

let salary = calculateSalary(50000, 10000);

displaySalary("Rahul", salary);


Output:

Employee: Rahul
Total Salary: 60000


This example demonstrates how functions help organize and reuse business logic.

15. Common Mistakes Beginners Should Avoid

โ€ข Forgetting to call a function after declaring it.

โ€ข Confusing parameters with arguments.

โ€ข Forgetting the return statement.

โ€ข Using variables outside their scope.

โ€ข Confusing arrow functions with regular functions.

โ€ข Passing incorrect arguments.

โ€ข Creating unnecessarily large functions.

โ€ข Forgetting that a function without an explicit return statement returns undefined.

16. Quick Revision: Types of Functions

๐Ÿ”น Function Declaration โžœ Defines a function using the function keyword.

๐Ÿ”น Function Expression โžœ Stores a function inside a variable.

๐Ÿ”น Arrow Function โžœ Provides shorter function syntax.

๐Ÿ”น Anonymous Function โžœ Function without a name.

๐Ÿ”น Callback Function โžœ Function passed as an argument to another function.

๐Ÿ”น IIFE โžœ Function that executes immediately after definition.

๐Ÿ”น Higher-Order Function โžœ Accepts or returns another function.

๐Ÿ”น Recursive Function โžœ A function that calls itself.

Key Takeaways

โ€ข Functions make code reusable and organized.

โ€ข Parameters allow functions to accept input.

โ€ข Return statements send results back.

โ€ข Arrow functions simplify function syntax.

โ€ข Callbacks allow functions to work with other functions.

โ€ข Scope determines variable accessibility.

โ€ข Higher-order functions are important in modern JavaScript.

Double Tap โค๏ธ For More
โค7
๐— ๐—œ๐—–๐—ฅ๐—ข๐—ฆ๐—ข๐—™๐—ง ๐—ฃ๐—ข๐—ช๐—˜๐—ฅ ๐—•๐—œ โ€“ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜! ๐Ÿ“Š

๐Ÿ˜ Want to master Power BI & Data Analytics without spending โ‚น1?

๐ŸŽ“ Explore Microsoft's FREE Power BI learning resources!

โœ… Data Visualization & Dashboards
โœ… Power Query & Data Cleaning
โœ… DAX Formulas & Data Modeling
โœ… Business Intelligence Skills

๐ŸŽฏ Perfect for Students, Freshers & Aspiring Data Analysts!

๐Ÿ”— ๐—Ÿ๐—ถ๐—ป๐—ธ ๐Ÿ‘‡:-

https://pdlink.in/4t3Jl0E

๐Ÿ“Œ SAVE & SHARE with friends interested in Data Analytics! ๐Ÿ”ฅ
โค1
๐—ง๐—ข๐—ฃ ๐Ÿฑ ๐—ฃ๐—Ÿ๐—”๐—ง๐—™๐—ข๐—ฅ๐— ๐—ฆ ๐—ง๐—ข ๐—™๐—œ๐—ก๐—— ๐—›๐—œ๐—š๐—›-๐—ฃ๐—”๐—ฌ๐—œ๐—ก๐—š ๐—ฅ๐—˜๐— ๐—ข๐—ง๐—˜ ๐—ง๐—˜๐—–๐—› ๐—๐—ข๐—•๐—ฆ!

Explore 5 platforms to discover remote opportunities in:

๐Ÿ’ป Software Development
๐Ÿ“Š Data Analytics
๐Ÿค– AI & Machine Learning
โ˜๏ธ Cloud Computing
๐Ÿ” Cybersecurity

โœ… Work-From-Home Opportunities
โœ… Explore Global Tech Companies
โœ… Find Jobs Matching Your Skills

๐Ÿ”— ๐—Ÿ๐—ถ๐—ป๐—ธ ๐Ÿ‘‡:-

https://pdlink.in/4C6fqci

๐Ÿ“Œ SAVE & SHARE with friends looking for remote jobs! ๐Ÿ”ฅ
โค1
๐—™๐—ฅ๐—˜๐—˜ ๐—ข๐—ป๐—น๐—ถ๐—ป๐—ฒ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ๐—ฐ๐—น๐—ฎ๐˜€๐˜€ ๐—ข๐—ป ๐—”๐—œ | ๐—•๐˜‚๐—ถ๐—น๐—ฑ ๐—”๐—œ-๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ง๐—ฒ๐—ฐ๐—ต ๐—–๐—ฎ๐—ฟ๐—ฒ๐—ฒ๐—ฟ๐Ÿ˜

- Get Exclusive 90-Day MAANG Career Roadmap

- Identify Which AI-Era Roles Companies Are Hiring For Now

๐ŸŽ“Eligibility :- Students ,Freshers & Working Professionals

๐—ฅ๐—ฒ๐—ด๐—ถ๐˜€๐˜๐—ฒ๐—ฟ ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡ :-

https://pdlink.in/4zQvjC2

Date:- 21st Nov 2026 Time:- 5:00 PM (IST)
๐Ÿ’ป JavaScript Learning Series: Day 7

Topic 7: Arrays in JavaScript

Arrays are one of the most important concepts in JavaScript.

An array is a special type of object used to store multiple values in a single variable.

Instead of creating separate variables for every value, you can store them together in an array.

Example:

Without an array:

let fruit1 = "Apple";
let fruit2 = "Mango";
let fruit3 = "Banana";


Using an array:

let fruits = ["Apple", "Mango", "Banana"];

console.log(fruits);


Output:

["Apple", "Mango", "Banana"]


Let's understand arrays step by step.

1. Creating an Array

You can create an array using square brackets [].

let fruits = ["Apple", "Mango", "Banana"];
let numbers = [10, 20, 30, 40];
let mixed = ["Rahul", 25, true, 50000];

console.log(fruits);
console.log(numbers);
console.log(mixed);


JavaScript arrays can contain different data types.

You can also create an array using the Array constructor:

let numbers = new Array(10, 20, 30);

console.log(numbers);


2. Accessing Array Elements

Array elements are accessed using their index positions.

Important: JavaScript arrays use zero-based indexing.

โ€ข First element โžœ Index 0

โ€ข Second element โžœ Index 1

โ€ข Third element โžœ Index 2

โ€ข Fourth element โžœ Index 3

Example:

console.log(fruits[0]);
console.log(fruits[1]);
console.log(fruits[2]);


Output:

Apple
Mango
Banana


3. Modifying Array Elements

You can change an array element by accessing its index.

fruits[1] = "Orange";
console.log(fruits);


Output:

["Apple", "Orange", "Banana"]


The element at index 1 has been replaced.

4. Finding Array Length

The length property returns the total number of elements in an array.

console.log(fruits.length);


Output: 3

You can also use it to access the last element:

let lastFruit = fruits[fruits.length - 1];

console.log(lastFruit);


Output: Banana

5. Adding Elements to an Array

JavaScript provides several methods to add elements.

A. push()

Adds an element at the end of an array.

let fruits = ["Apple", "Mango"];

fruits.push("Banana");
console.log(fruits);


Output: ["Apple", "Mango", "Banana"]

B. unshift()

Adds an element at the beginning of an array.

fruits.unshift("Banana");
console.log(fruits);


Output: ["Banana", "Apple", "Mango"]

6. Removing Elements from an Array

A. pop()

Removes the last element.

fruits.pop();
console.log(fruits);


Output: ["Apple", "Mango"]

B. shift()

Removes the first element.

fruits.shift();
console.log(fruits);


Output: ["Mango", "Banana"]

7. Important Array Methods

Let's understand some commonly used array methods.

A. indexOf()

Returns the first index of a specified element, or -1 if it is not found.

console.log(fruits.indexOf("Mango"));


Output: 1

B. includes()

Checks whether an array contains a particular element.

console.log(fruits.includes("Mango"));


Output: true

C. slice()

Returns a portion of an array without modifying the original array.
โค1
let numbers = [10, 20, 30, 40, 50];

let result = numbers.slice(1, 4);

console.log(result);


Output: [20, 30, 40]

D. splice()

Adds, removes, or replaces elements in the original array.

fruits.splice(1, 1, "Orange");
console.log(fruits);


Output: ["Apple", "Orange", "Banana"]

Here:

โ€ข 1 โžœ Starting index.

โ€ข 1 โžœ Number of elements to remove.

โ€ข "Orange" โžœ New element to insert.

8. Iterating Through Arrays

You can use loops to access every element in an array.

A. Using for Loop

for (let i = 0; i < fruits.length; i++) {
console.log(fruits[i]);
}


B. Using for...of

for (let fruit of fruits) {
console.log(fruit);
}


C. Using forEach()

Executes a callback function for each array element.

let numbers = [10, 20, 30];

numbers.forEach(function(num) {
console.log(num);
});


9. map() Method

The map() method creates a new array by transforming every element of the original array.

Example: Multiply Every Number by 2

let numbers = [1, 2, 3, 4, 5];

let result = numbers.map(num => num * 2);

console.log(result);


Output:

[2, 4, 6, 8, 10]


Use case: Transforming data, formatting values, and preparing information for display.

10. filter() Method

The filter() method creates a new array containing elements that satisfy a given condition.

Example: Find Even Numbers

let numbers = [1, 2, 3, 4, 5, 6];

let result = numbers.filter(num => num % 2 === 0);

console.log(result);


Output:

[2, 4, 6]


Use case: Filtering products, employees, customers, and records based on conditions.

11. reduce() Method

The reduce() method processes array elements and combines them into a single accumulated result.

Example: Calculate Total

let numbers = [10, 20, 30, 40];

let total = numbers.reduce((sum, num) => {
return sum + num;
}, 0);

console.log(total);


Output: 100

Use case: Calculating totals, sums, averages, and aggregations.

12. find() Method

Returns the first element that satisfies a specified condition.

let numbers = [10, 20, 30, 40];
let result = numbers.find(num => num > 20);

console.log(result);


Output: 30

Unlike filter(), find() returns only the first matching element.

13. sort() Method

Used to sort array elements.

let numbers = [40, 10, 30, 20];

numbers.sort((a, b) => a - b);
console.log(numbers);


Output: [10, 20, 30, 40]

For descending order:

numbers.sort((a, b) => b - a);
console.log(numbers);


Important: Calling sort() directly without a comparator sorts elements as strings by default.

14. Joining Array Elements

The join() method combines array elements into a single string.

let result = fruits.join(", ");
console.log(result);


Output:

Apple, Mango, Banana


15. Multidimensional Arrays

A multidimensional array contains other arrays as elements.

let numbers = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
];

console.log(numbers[0][1]);
console.log(numbers[2][2]);


Output:

2
9
These arrays are useful for matrices, tables, grids, and structured datasets.

16. Arrays of Objects

In real-world applications, arrays frequently store multiple objects.

Example: Employee Records

let employees = [
{
name: "Rahul",
salary: 50000
},
{
name: "Priya",
salary: 60000
},
{
name: "Amit",
salary: 45000
}
];

console.log(employees[0].name);
console.log(employees[1].salary);


Output:

Rahul
60000


You can also filter employees based on salary:

let highSalary = employees.filter(
emp => emp.salary > 50000
);

console.log(highSalary);


This is commonly used when working with API responses and business applications.

17. Real-World Example: Shopping Cart

Let's build a simple shopping cart using JavaScript arrays.

let cart = [
{ name: "Laptop", price: 50000 },
{ name: "Mouse", price: 1000 },
{ name: "Keyboard", price: 2000 }
];

let total = cart.reduce((sum, item) => {
return sum + item.price;
}, 0);

console.log("Cart Items:", cart.length);
console.log("Total Amount:", total);


Output:

Cart Items: 3
Total Amount: 53000


This example combines arrays, objects, and the reduce() method.

18. Important Array Methods, Quick Revision

๐Ÿ”น push() โžœ Adds an element at the end.

๐Ÿ”น pop() โžœ Removes the last element.

๐Ÿ”น shift() โžœ Removes the first element.

๐Ÿ”น unshift() โžœ Adds an element at the beginning.

๐Ÿ”น map() โžœ Transforms every element and returns a new array.

๐Ÿ”น filter() โžœ Returns elements matching a condition.

๐Ÿ”น reduce() โžœ Combines elements into a single result.

๐Ÿ”น forEach() โžœ Executes a function for every element.

๐Ÿ”น find() โžœ Returns the first matching element.

๐Ÿ”น includes() โžœ Checks whether an element exists.

๐Ÿ”น indexOf() โžœ Returns the first matching index.

๐Ÿ”น slice() โžœ Extracts a portion without modifying the original array.

๐Ÿ”น splice() โžœ Adds, removes, or replaces elements in the original array.

๐Ÿ”น sort() โžœ Sorts array elements.

๐Ÿ”น join() โžœ Converts array elements into a string.

Double Tap โค๏ธ For More
โค1
๐—™๐—ฅ๐—˜๐—˜ ๐—Ÿ๐—˜๐—”๐—ฅ๐—ก๐—œ๐—ก๐—š ๐—”๐—ก๐—— ๐—–๐—˜๐—ฅ๐—ง๐—œ๐—™๐—œ๐—–๐—”๐—ง๐—œ๐—ข๐—ก ๐—ฅ๐—˜๐—ฆ๐—ข๐—จ๐—ฅ๐—–๐—˜๐—ฆ ๐—ง๐—ข ๐—•๐—จ๐—œ๐—Ÿ๐—— ๐—ฌ๐—ข๐—จ๐—ฅ ๐—–๐—ข๐——๐—œ๐—ก๐—š ๐—ฆ๐—ž๐—œ๐—Ÿ๐—Ÿ๐—ฆ๐Ÿ˜

Explore free courses and resources to learn:

โœ… Beginner-Friendly Resources
โœ… Self-Paced Learning
โœ… Build Practical Coding Skills
โœ… Explore Certification Opportunities

๐ŸŽฏ Perfect for Students, Freshers & Aspiring Developers!

๐—Ÿ๐—ถ๐—ป๐—ธ๐Ÿ‘‡:-

https://pdlink.in/4fbyA6I

๐Ÿ“Œ SAVE & SHARE with friends looking for FREE courses๐Ÿ”ฅ
๐ŸŒ Web Development Tips for Beginners

Starting web development can feel overwhelming because there are so many technologies to learn.

HTML, CSS, JavaScript, React, Node.js, databases, Git, APIsโ€ฆ ๐Ÿ˜ตโ€๐Ÿ’ซ

The key is not to learn everything at once.

Here are some practical tips that can make your journey much easier ๐Ÿ‘‡

1๏ธโƒฃ Master the Basics Before Frameworks

Don't rush into React just because everyone is talking about it.

First understand:

HTML โ†’ Structure

CSS โ†’ Styling

JavaScript โ†’ Logic

Once these are clear, frameworks become much easier to understand.

2๏ธโƒฃ Don't Just Watch Tutorials

Watching 100 hours of tutorials won't make you a developer.

After learning a concept, immediately build something with it.

For example:

Learn Forms

โ†“

Build a Registration Form

Learn DOM

โ†“

Build a To-Do List

Learn APIs

โ†“

Build a Weather App

๐Ÿ‘‰ Learn โ†’ Build โ†’ Break โ†’ Fix โ†’ Repeat.

3๏ธโƒฃ Learn by Building Small Projects

Don't start with:

โŒ "I'll build the next Amazon."

Start with:

โœ” Calculator

โœ” To-Do App

โœ” Quiz App

โœ” Weather App

โœ” Expense Tracker

โœ” Notes App

โœ” Portfolio Website

Small projects teach you how to actually solve problems.

4๏ธโƒฃ Learn JavaScript Properly

JavaScript is one of the most important skills in modern web development.

Focus on:

Variables

Functions

Arrays

Objects

Loops

DOM

Events

Promises

Async/Await

Fetch API

ES6+

Modules

Error Handling

Don't just memorize syntax.

Understand why and when to use each concept.

5๏ธโƒฃ Learn to Read Documentation

A professional developer doesn't Google every problem and copy the first answer.

Learn to use official documentation.

When you encounter a problem:

Understand the problem

โ†“

Search documentation

โ†“

Try a solution

โ†“

Test it

โ†“

Understand why it works

This skill becomes extremely valuable as you progress.

6๏ธโƒฃ Get Comfortable With Developer Tools

Learn to use your browser's DevTools.

Important sections include:

Elements

Console

Network

Application

Sources

For example, if an API isn't working, the Network tab can help you inspect:

Request

Response

Status code

Headers

Payload

7๏ธโƒฃ Learn Git Early

Don't wait until you're applying for jobs.

Learn basic Git commands:

git init

git add .

git commit -m "Initial commit"

git status

git push

git pull

Use GitHub to maintain your projects.

Your GitHub profile can become part of your developer portfolio.

8๏ธโƒฃ Understand How Websites Actually Work

Don't just learn code.

Understand the fundamentals:

Browser

โ†“

HTTP Request

โ†“

Server

โ†“

Database

โ†“

Server Response

โ†“

Browser

Learn the basics of:

HTTP

URLs

DNS

APIs

JSON

Status codes

Client vs Server

Databases

This knowledge makes full-stack development much easier.

9๏ธโƒฃ Don't Copy-Paste Code You Don't Understand

You can use AI tools and online resources.

But avoid blindly copying code.

If you get:

fetch("/api/users")

understand:

What is fetch()?

What is an API?

What does /api/users represent?

What does the response contain?

What happens if the request fails?

Understanding matters more than typing.

๐Ÿ”Ÿ Learn Debugging

Errors are not failures.

They are clues.

When you see:

404

500

TypeError

SyntaxError

undefined

Don't immediately delete your code.

Read the error.

Ask:

What happened?
โค3๐Ÿ‘1
Where did it happen?

Why did it happen?

How can I reproduce it?

How can I fix it?

Debugging is one of the most important developer skills.

1๏ธโƒฃ1๏ธโƒฃ Make Your Projects Responsive

A website shouldn't look good only on your laptop.

Test it on:

๐Ÿ“ฑ Mobile

๐Ÿ“ฑ Tablet

๐Ÿ’ป Laptop

๐Ÿ–ฅ๏ธ Desktop

Learn:

Flexbox

CSS Grid

Media Queries

Responsive Units

1๏ธโƒฃ2๏ธโƒฃ Build Projects Without Following Tutorials

Tutorial projects are useful initially.

But eventually, close the tutorial and build something yourself.

For example:

Tutorial:

Build a To-Do App

Your Version:

Build an Expense Tracker

This forces you to think instead of follow instructions.

1๏ธโƒฃ3๏ธโƒฃ Deploy Your Projects

A project sitting only on your laptop doesn't demonstrate deployment skills.

Learn how to deploy your applications.

For example:

Code

โ†“

GitHub

โ†“

Deployment Platform

โ†“

Live Website ๐ŸŒ

Add the live link to your portfolio.

1๏ธโƒฃ4๏ธโƒฃ Don't Learn Too Many Technologies at Once

Avoid this:

HTML

CSS

JavaScript

React

Angular

Vue

Node

Django

Java

Python

PHP

MongoDB

AWS

Docker

Kubernetes

๐Ÿ˜ตโ€๐Ÿ’ซ

Instead:

HTML

โ†“

CSS

โ†“

JavaScript

โ†“

React

โ†“

Node.js

โ†“

Database

โ†“

Deployment

Build a strong foundation before expanding.

1๏ธโƒฃ5๏ธโƒฃ Create a Portfolio

Your portfolio should show:

About

Skills

Projects

GitHub

Live Projects

Contact

For every major project, explain:

โ€ข What problem it solves

โ€ข Technologies used

โ€ข Key features

โ€ข Challenges faced

โ€ข What you learned

โ€ข Live demo

โ€ข GitHub repository

๐Ÿง  Don't compare your Day 10 with someone's Year 5.

You will:

Get confused

โ†“

Make mistakes

โ†“

Get stuck

โ†“

Debug

โ†“

Understand

โ†“

Improve

That's normal.

Every developer goes through this process.

๐Ÿš€ Double Tap โค๏ธ For More
โค13
๐—™๐—ฅ๐—˜๐—˜ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ๐—ฐ๐—น๐—ฎ๐˜€๐˜€ ๐—ข๐—ป ๐—Ÿ๐—ฎ๐˜๐—ฒ๐˜€๐˜ ๐—ง๐—ฒ๐—ฐ๐—ต๐—ป๐—ผ๐—น๐—ผ๐—ด๐—ถ๐—ฒ๐˜€ ๐Ÿ˜

Get the 90-Day Plan to Build 1% Tech Career

- AI
- GenAI
- Data Analytics
- Fullstack
- UI/UX

Use Coupon Code " ๐—›๐—–๐—Ÿ๐—š๐—จ๐—ฉ๐—œ๐Ÿญ๐Ÿฌ๐Ÿฌ " To Register For FREE

๐—ฅ๐—ฒ๐—ด๐—ถ๐˜€๐˜๐—ฒ๐—ฟ ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡ :-

https://pdlink.in/4fFMe22

Date:- 21st Nov 2026 Time:- 5:00 PM (IST)
๐—•๐—ข๐—ข๐—ฆ๐—ง ๐—ฌ๐—ข๐—จ๐—ฅ ๐—ฅ๐—˜๐—ฆ๐—จ๐— ๐—˜ ๐—ช๐—œ๐—ง๐—› ๐Ÿฐ ๐—™๐—ฅ๐—˜๐—˜ ๐—œ๐—ก-๐——๐—˜๐— ๐—”๐—ก๐—— ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ! ๐ŸŽ“

๐Ÿ˜ Want to learn high-demand tech skills without spending โ‚น1?

๐Ÿ“Š Data Analytics
๐Ÿ’ป Full Stack Development
๐Ÿค– AI & Generative AI
โ˜๏ธ Cloud Computing

๐ŸŽฏPerfect for Students, Freshers & Job Seekers!

๐—Ÿ๐—ถ๐—ป๐—ธ๐Ÿ‘‡:-

https://pdlink.in/4jsqetS

๐Ÿ“Œ SAVE & SHARE with friends looking for FREE courses๐Ÿ”ฅ
๐—–๐—œ๐—ฆ๐—–๐—ข ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! ๐ŸŽ“

Boost your Resume & LinkedIn Profile with valuable tech skills

Explore FREE Cisco learning resources! ๐Ÿš€

๐ŸŒ Networking Fundamentals
๐Ÿ” Cybersecurity
โ˜๏ธ Cloud & DevOps
๐Ÿ’ป IT Fundamentals

๐ŸŽฏ Perfect for Students, Freshers & Job Seekers!

๐—Ÿ๐—ถ๐—ป๐—ธ๐Ÿ‘‡:-

https://pdlink.in/3WPl0Qg

๐Ÿ“Œ SAVE & SHARE with friends interested in Tech Careers! ๐Ÿ”ฅ
โค1