swstack

swstack (102)

swstack

JavaScript - 22

JavaScript - 22: To-Do List (Add Items) Create a simple to-do list where users can type a task and add it to the list by clicking a button. Display all tasks in an unordered list. const taskInput = document.getElementById("taskInput"); const addBtn = document.getElementById("addBtn"); const todoList…

Continue reading...
swstack

JavaScript - 21

JavaScript - 21: Form Handling Create a simple form with name and age inputs. When the user clicks "Submit", show a personalized message below using the values they entered. const form = document.getElementById("userForm"); const result = document.getElementById("result"); form.addEventListener("submit", function(e) { e.preventDefault(); const name = document.getElementById("name").value;…

Continue reading...
swstack

JavaScript - 20

JavaScript - 20: Mini Project - Simple Counter Create a working counter with Increase, Decrease, and Reset buttons. let count = 0; const countDisplay = document.getElementById("count"); const increaseBtn = document.getElementById("increase"); const decreaseBtn = document.getElementById("decrease"); const resetBtn = document.getElementById("reset"); increaseBtn.addEventListener("click", () => { count++; countDisplay.textContent =…

Continue reading...
swstack

JavaScript - 19

JavaScript - 19: While Loops Use a while loop to print numbers from 1 to 10. Then create another while loop that doubles a number until it exceeds 100. let i = 1; while (i <= 10) { console.log("Count:", i); i++; } let num =…

Continue reading...
swstack

JavaScript - 18

JavaScript - 18: If / Else with Multiple Conditions Create a simple grade calculator. Based on a variable score, print the correct letter grade using if / else if / else: let score = 85; if (score >= 90) { console.log("Your grade is: A"); }…

Continue reading...