This repository contains practical exercises to practice JavaScript Array Methods and DOM Manipulation.
Perfect for beginners who want to strengthen their JS fundamentals.
- Array Methods Exercises
- DOM Exercises
let numbers = [1, 2, 3, 4, 5];
// TODO: Use map() to create a new array with each number multiplied by 2
let nums = [10, 15, 20, 25, 30];
// TODO: Use filter() to keep only even numbers
let prices = [5, 10, 15, 20];
// TODO: Use reduce() to calculate the total sum
let fruits = ["apple", "banana", "cherry", "mango"];
// TODO: Use find() to get the fruit "cherry"
// TODO: Use includes() to check if "banana" exists
let names = ["Zara", "Alex", "John", "Maya"];
// TODO: Sort alphabetically
// TODO: Reverse the order
<button id="btn">Click Me</button>
<p id="message">Hello!</p>
// TODO: When button is clicked, change <p> text to "You clicked the button!"
<ul id="myList">
<li>Item 1</li>
<li>Item 2</li>
</ul>
<button id="addBtn">Add Item</button>
// TODO: When button is clicked, add <li>Item 3</li> to the list
<button id="toggleBtn">Toggle Background</button>
// TODO: Each time button is clicked, switch body background between "white" and "lightblue"
<input type="text" id="nameInput" placeholder="Enter your name">
<button id="showBtn">Show Name</button>
<p id="output"></p>
// TODO: When button is clicked, display "Hello, [name]" inside <p>
<ul id="taskList">
<li>Task 1 <button class="delBtn">Delete</button></li>
<li>Task 2 <button class="delBtn">Delete</button></li>
</ul>
// TODO: When "Delete" button is clicked, remove that <li> from the list