0% found this document useful (0 votes)
4 views3 pages

Class Notes

This document outlines a 12-day learning plan for JavaScript, covering key concepts such as objects, arrays, and their methods. It includes code examples for creating, modifying, and accessing objects and arrays, as well as techniques for sorting, filtering, and transforming data. The final day summarizes the topics learned and encourages further practice.

Uploaded by

tarunsharma70064
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Class Notes

This document outlines a 12-day learning plan for JavaScript, covering key concepts such as objects, arrays, and their methods. It includes code examples for creating, modifying, and accessing objects and arrays, as well as techniques for sorting, filtering, and transforming data. The final day summarizes the topics learned and encourages further practice.

Uploaded by

tarunsharma70064
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

# JavaScript Learning Notes (Day 1 - Day 12)

## **Day 1: Introduction to Objects**


### **Creating an Object**
```js
const person = {
name: "Tarun",
age: 19,
city: "Udhampur"
};
console.log(person);
```
### **Accessing Object Properties**
```js
console.log(person.name); // Tarun
console.log(person.age); // 19
```

## **Day 2: Looping through an Object**


### **Using `for...in` loop**
```js
for (let key in person) {
console.log(key, ":", person[key]);
}
```

## **Day 3: Modifying Objects**


### **Adding and Updating Properties**
```js
person.hobby = "Coding"; // Adding new property
person.city = "Delhi"; // Updating existing property
console.log(person);
```
### **Deleting a Property**
```js
delete person.hobby;
console.log(person);
```

## **Day 4: Methods in Objects**


### **Adding Methods to an Object**
```js
const person = {
name: "Tarun",
age: 19,
introduce: function() {
return `Nice meeting you, ${this.name}. You are ${this.age} years old.`;
}
};
console.log(person.introduce());
```

## **Day 5: Arrays in JavaScript**


### **Creating and Accessing Arrays**
```js
const fruits = ["Apple", "Mango", "Grapes", "Guava", "Banana"];
console.log(fruits[0]); // Apple
console.log(fruits[fruits.length - 1]); // Banana
```

## **Day 6: Modifying Arrays**


### **Adding and Removing Elements**
```js
fruits.push("Orange"); // Add at the end
fruits.unshift("Pineapple"); // Add at the beginning
fruits.pop(); // Remove last element
fruits.shift(); // Remove first element
console.log(fruits);
```

## **Day 7: Splicing and Slicing Arrays**


### **Using `splice()` to Add/Remove Elements**
```js
fruits.splice(1, 0, "Strawberry"); // Insert at index 1
console.log(fruits);
```
### **Using `slice()` to Extract Elements**
```js
const newFruits = fruits.slice(-3); // Get last 3 elements
console.log(newFruits);
```

## **Day 8: Combining and Searching Arrays**


### **Concatenating Arrays**
```js
const arr1 = ["Apple", "Mango"];
const arr2 = ["Grapes", "Banana"];
const arr3 = arr1.concat(arr2);
console.log(arr3);
```
### **Checking for an Element in an Array**
```js
console.log(fruits.includes("Mango")); // true
```

## **Day 9: Finding and Filtering Elements**


### **Finding an Element**
```js
const numbers = [10, 20, 30, 40, 50];
const firstNumGreaterThan30 = numbers.find(num => num > 30);
console.log(firstNumGreaterThan30); // 40
```
### **Filtering Elements**
```js
const evenNumbers = numbers.filter(num => num % 2 === 0);
console.log(evenNumbers); // [10, 20, 30, 40, 50]
```

## **Day 10: Sorting Arrays**


### **Sorting Numbers in Ascending Order**
```js
const num = [10, 36, 48, 100, 9];
num.sort((a, b) => a - b);
console.log(num); // [9, 10, 36, 48, 100]
```

## **Day 11: Transforming Arrays with Map & Reduce**


### **Using `map()` to Square Numbers**
```js
const numbers = [2, 4, 6, 8];
const squaredNumbers = numbers.map(num => num * num);
console.log(squaredNumbers); // [4, 16, 36, 64]
```
### **Using `reduce()` to Sum Numbers**
```js
const sum = numbers.reduce((acc, curr) => acc + curr, 0);
console.log(sum); // 20
```
### **Finding Maximum Value in an Array**
```js
const maxNum = numbers.reduce((acc, curr) => (acc > curr ? acc : curr),
numbers[0]);
console.log(maxNum); // 8
```
### **Finding Minimum Value in an Array**
```js
const minNum = numbers.reduce((acc, curr) => (acc < curr ? acc : curr),
numbers[0]);
console.log(minNum); // 2
```

## **Day 12: Summary and Practice**


You have now covered:
- Objects and methods
- Arrays and their operations (adding, removing, searching, and modifying elements)
- Sorting, filtering, and transforming arrays using `map()`, `reduce()`, and
`find()`.

---
This is a great foundation in JavaScript! 🚀 Let me know if you need further
explanations or practice tasks!

You might also like