Activity 9
Correct Answers
1. What quantifier matches 0 or more repetitions? ✅ *
2. What method converts JavaScript objects to JSON? ✅ JSON.stringify()
3. What does the try...catch statement do? ✅ Handles errors in code
4. What is a common debugging tool? ✅ console.log()
5. What does regex stand for? ✅ Regular expressions
6. Which keyword is used to manually throw an error? ✅ throw
7. How do you validate email addresses in JavaScript? ✅ Use regex
8. How do you set breakpoints in Chrome? ✅ Open Inspect and navigate to Sources tab
9. Which method retrieves a key-value pair from local storage? ✅ window.localStorage.getItem()
10. What is the output of JSON.stringify()? ✅ A JSON string
Instructions:
Set Up Your Development Environment
- Open your preferred code editor (e.g., VS Code, Sublime Text, or Notepad++).
- Create a new file and save it with the
.htmlextension (e.g., Activity6.html).
Email Validation using Regular Expressions
- Use JavaScript to validate email input using regular expressions.
- Display a message indicating whether the email is valid or invalid.
Local Storage Example
- Allow the user to input their name and save it in local storage.
- Retrieve the saved name and display it on the page after it has been saved.
Final Output
- ✅ A webpage that validates an email address using regular expressions and displays the result.
- ✅ A webpage that saves and retrieves a name using local storage.
- ✅ The page should display a validation message when the user inputs an email and a saved name after it is stored.