swstack

swstack (102)

swstack

JavaScript - 12

JavaScript - 12: Introduction to the DOM Select the paragraph with id "output-text" and change its text using document.getElementById(). document.getElementById("output-text").textContent = "Success! JavaScript is now controlling this text 🎉";

Continue reading...
swstack

JavaScript - 11

JavaScript - 11: let, const, and var Create variables using let and const. Try to reassign them and see what happens. Use console.log() to observe the results. let age = 20; age = 21; console.log("Age with let:", age); const name = "Mia"; // name =…

Continue reading...
swstack

JavaScript - 10

JavaScript - 10: Objects Create an object called student with properties: name, age, grade, and subjects (an array). Then use console.log() to print some information about the student. let student = { name: "Liam", age: 17, grade: "A", subjects: ["Math", "Physics", "English", "History"] }; console.log(student.name…

Continue reading...
swstack

JavaScript - 9

JavaScript - 9: Array Methods Create an array called numbers. Use array methods to: let numbers = [5, 10, 15, 20]; numbers.push(25); numbers.shift(); numbers.forEach(num => { console.log(num * 2); });

Continue reading...
swstack

JavaScript - 8

JavaScript - 8: Loops (for loop) Create an array of numbers. Use a for loop to go through the array and print each number and its square. let numbers = [2, 5, 8, 10, 3]; for (let i = 0; i < numbers.length; i++) {…

Continue reading...