Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
2024-spring-dmd-3475/week-01/js/week-01.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 lines (25 sloc)
1.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Week 01 | |
*/ | |
// 1. Change the value to your first name: | |
let firstName = 'Simon'; | |
// 2. Change the value to your age: | |
let age = 72; | |
// 3. Complete the sentence: "I'm taking this course because..." | |
let whyImTakingThisCourse = "I want to learn how to code and build interactive websites."; | |
// 4. You're all done. Take a look at the code below to see how this all works. | |
// Get a reference to the button in index.html with the class "alert-btn" | |
let button = document.querySelector('button.alert-btn'); | |
// Add an event listener for the click event to the button | |
if(button !== null){ | |
button.addEventListener('click', function() { | |
// Create a message to display in the alert | |
let message = 'My name is ' + firstName + | |
' and I am ' + age + ' years old. ' + | |
'I am taking this course because ' + whyImTakingThisCourse; | |
// Display an alert with the message we created | |
alert(message); | |
}); | |
} | |
// Export the variables so we can use them in the tests | |
export { firstName, age, whyImTakingThisCourse }; |