You will:
- Use the Starter Code Repo,
- Code your solution,
- Commit changes to your repo
- Submit GitHub Repo Link to LMS [JSL01] Submission Project Tab
Imagine you are building a virtual pet adoption website, and you need to create a JavaScript function that checks if the user has entered valid pet adoption details. Write a function that takes a string as input and validates if it follows a specific syntax, such as starting with "pet_" followed by a combination of letters and numbers. If the input follows the syntax, return "Valid Syntax," otherwise, return "Invalid Syntax."
- In the script.js file, complete the validateSyntax function to check if the input string starts with "pet_" and is followed by a combination of letters and numbers.
- If the input follows the correct syntax, set result to "Valid Syntax." Otherwise, set it to "Invalid Syntax."
- Test your function by entering different strings in the input box and clicking the validate button.
- Run the index.html challenge in a browser.
- Enter different pet adoption details in the input box and click the validate button to see the results.
- Make sure your solution works for a variety of inputs.
- Open the console and debug your code until there are no errors.
- Save the HTML, CSS, and JavaScript files in a folder.
- Open the folder in VSCode.
- Right-click on index.html and open with a browser (use Live Server if available).
- Modify the script.js file to correct the syntax errors and save the file.
- Refresh your browser to view the changes.
This challenge helps students practice basic string manipulation and validation in JavaScript, along with simple DOM manipulation to create an interactive and user-friendly interface.
Check out the practice challenges on Scrimba here: https://scrimba.com/playlist/pqPae6ZH7