# JavaScript Array Methods x Hera Pheri

A hot summer day in Mumbai, a small chawl, and three unemployed men – **Baburao Ganpatrao Apte (Babu Bhaiya), Raju, and Shyam**. Their lives were already a mess of **Hera Pheri**, when one day, a brilliant idea struck – **learning JavaScript!**

Babu Bhaiya said, “How do we double our money? We must learn this!”  
Raju replied, “It’s all about array method, Babu Bhaiya. If we master this, our life is set!”  
Shyam grabbed a laptop, and all three dived into the magical world of JavaScript arrays.

---

## **1\.** `push()` – Paisa Add Karo Re Baba!

Raju started explaining, “`push()` is like adding money to our savings.”

```javascript
let money = ['₹500', '₹1000'];
money.push('₹2000');
console.log(money); // ['₹500', '₹1000', '₹2000']
```

Babu Bhaiya exclaimed, “Arre wah! This is a great scheme! Double, double!”

---

## **2\.** `pop()` – Paisa Gaya, System Lucha!

When Babu Bhaiya went to the ATM, the system behaved like `pop()` and removed the last amount.

```javascript
money.pop();
console.log(money); // ['₹500', '₹1000']
```

Shyam laughed, “Babu Bhaiya, this method is just like your wallet – money disappears instantly!”

---

## **3\.** `shift()` – Babu Bhaiya Ka Udhaar

Raju said, “We must clear Babu Bhaiya’s debts first. That’s why we use `shift()`.”

```javascript
let debts = ['Raju ka ₹500', 'Shyam ka ₹1000', 'Bank ka ₹2000'];
debts.shift();
console.log(debts); // ['Shyam ka ₹1000', 'Bank ka ₹2000']
```

Babu Bhaiya shouted, “Arre! Why is my money always the first to go?”

---

## **4\.** `unshift()` – Naya Loan Aya Hai!

When Raju took a new loan, it got added to the beginning using `unshift()`.

```javascript
debts.unshift('Raju ka naya ₹3000');
console.log(debts); // ['Raju ka naya ₹3000', 'Shyam ka ₹1000', 'Bank ka ₹2000']
```

Shyam smirked, “Raju, your loans are increasing like an infinite array!”

---

## **5\.** `map()` – Idea Chhapo!

Babu Bhaiya had an idea: “Let’s multiply our money by 10!”

```javascript
let money = [100, 200, 300];
let doubleMoney = money.map(amount => amount * 10);
console.log(doubleMoney); // [1000, 2000, 3000]
```

Raju shouted, “Arre Babu Bhaiya! This is the real **double-your-money** scheme!”

---

## **6\.** `filter()` – Sirf Munafa!

Shyam decided to filter out only **profit** transactions.

```javascript
let transactions = [-100, 500, -200, 1000, -50];
let profitOnly = transactions.filter(amount => amount > 0);
console.log(profitOnly); // [500, 1000]
```

Babu Bhaiya was impressed, “Just focus on profits! Who cares about losses?!”

---

## **7\.** `reduce()` – Sabko Ek Kar Dala!

Babu Bhaiya said, “Let’s calculate the total earnings for the year.”

```javascript
let money = [500, 1000, 1500, 2000];
let total = money.reduce((acc, curr) => acc + curr, 0);
console.log(total); // 5000
```

Shyam sighed, “Babu Bhaiya, your total money is just ₹5000!”  
Babu Bhaiya: “What?! Such a small total? System looted, re baba!”

---

## **8\.** `find()` – Raju Ka Loan Kahan Gaya?

Shyam asked, “Which loan belongs to Raju?”

```javascript
let loans = [{name: 'Raju', amount: 1000}, {name: 'Shyam', amount: 2000}];
let rajuLoan = loans.find(loan => loan.name === 'Raju');
console.log(rajuLoan); // {name: 'Raju', amount: 1000}
```

Raju laughed, “Arre! My loan was found so easily!”

---

## **9\.** `some()` – Koi Bhi Amir Hai Kya?

Babu Bhaiya wondered, “Check if anyone in the chawl is rich.”

```javascript
let bankBalance = [500, 1000, 1500, 10000];
let isAnyoneRich = bankBalance.some(amount => amount >= 10000);
console.log(isAnyoneRich); // true
```

Raju: “Yes, Babu Bhaiya, there’s one person who is rich!”  
Babu Bhaiya: “Who is he?! Where’s his money?!”

---

## **10\.** `every()` – Sab Gareeb Hain Kya?

Shyam asked, “Are all chawl residents poor?”

```javascript
let bankBalance = [500, 1000, 1500, 2000];
let allPoor = bankBalance.every(amount => amount < 10000);
console.log(allPoor); // true
```

Babu Bhaiya sighed, “Everyone’s in the same boat, re baba!”

---

## **Hera Pheri Ka Ant**

And just like that, **Babu Bhaiya, Raju, and Shyam** mastered JavaScript array methods! But… they were still broke!

Babu Bhaiya concluded with his legendary dialogue:  
**“System set hai re baba! Only money is missing!”**

![“System set hai re baba! Only money is missing!”](https://im.indiatimes.in/content/2020/Apr/maxresdefault_5e8459894bb6d.jpg?w=640&h=427&cc=1&webp=1&q=75 align="center")

And that, dear friends, was the **Hera Pheri x JavaScript Arrays** story! 😂
