JavaScript Practice Workbook - Week 1 & Week 2
Week 1: JavaScript Basics - Practice & Exercises
- Variables & Data Types (var, let, const)
- Practice:
1. Declare variables for name, age, isStudent.
2. Try re-assigning values to let vs const.
- Functions + Arrow Functions
- Practice:
1. Write a function that returns square of a number.
2. Convert it to an arrow function.
3. Write a function to return the larger of two numbers.
- Loops (for, while)
- Practice:
1. Print numbers from 1 to 10 using for and while loop.
2. Loop through an array of colors.
- if/else, switch
- Practice:
1. Write a function that checks if a number is positive, negative or zero.
2. Use switch to print day of the week for a number 1-7.
- Arrays (map, filter, reduce)
- Practice:
1. Use map to square each number in an array.
2. Use filter to get even numbers.
3. Use reduce to sum the values.
Week 2: Intermediate JavaScript - Practice & Exercises
JavaScript Practice Workbook - Week 1 & Week 2
- Objects
- Practice:
1. Create a student object with name, age, marks.
2. Write a method to greet using object.
- Destructuring
- Practice:
1. Destructure name and age from student object.
2. Destructure values from an array of fruits.
- Spread/Rest operators
- Practice:
1. Combine two arrays using spread.
2. Create a function that uses rest to accept any number of arguments.
- DOM Manipulation
- Practice (HTML + JS):
1. Change the text of an <h1> element using JS.
2. Toggle the background color of the page on button click.
- Event Listeners + Bubbling
- Practice:
1. Add a click event to a button that shows an alert.
2. Add bubbling example with nested divs and stop propagation.