Question
Hands-on Project 4-4 Hands-on Project 4-3 Type the name of a place, then click Submit: Submit var places = [,,,,]; // new array to store
Hands-on Project 4-3
In this project, you will use strict mode to strengthen the code used in one of the functions from Project 4-3. Strict mode enforces a number of rules that are considered good coding practices but are not enforced by default in JavaScript. One of the most basic of these rules is that all variables must be declared with the var keyword. In strict mode, declaring a new variable without the var keyword throws an error. The processInput() function in the file you debugged in Project 4-3 includes a number of variables declared without the var keyword. You'll specify that the function is to be executed in strict mode, and then use the resulting errors to identify and add the missing keywords.
1. Use the file manager for your operating system to copy all the files and subfolders from the Chapter04/HandsOnProject4-3 directory in your Data Files, and paste them in the Chapter04/HandsOnProject4-4 folder. Verify that you still have a copy in the Chapter04/HandsOnProject4-3 directory.
2. In your text editor, open index.htm from the Chapter04/HandsOnProject4-4 folder, and then in the comment section, title element, and h1 element, replace the text Hands-on Project 4-3 with Hands-on Project 4-4.
3. Scroll down to the script section at the bottom of the body section.
4. Add a new line at the top of the code block for the processInput()function, and then add a statement requesting that browsers interpret the function using strict mode.
5. Save your changes, open index.htm in a browser, and then test the operation of the page. The features that worked at the end of Project 4-3 no longer work.
6. Open the browser console, and examine any error messages that are logged. Use the browser tools to identify the lines missing var keywords, add the keywords in your text editor, save your changes, and then retest the page. Continue debugging until the page works as it did at the end of Project 4-3.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started