{ "key_pair_value_system": true, "answer_rating_count": "", "question_feedback_html": { "html_star": "", "html_star_feedback": "" }, "answer_average_rating_value": "", "answer_date_js": "2024-08-31T02:29:58-04:00", "answer_date": "2024-08-31 02:29:58", "is_docs_available": "", "is_excel_available": "", "is_pdf_available": "", "count_file_available": 0, "main_page": "student_question_view", "question_id": "8775858", "url": "\/study-help\/questions\/for-this-discussion-we-will-be-looking-at-a-simple-8775858", "question_creation_date_js": "2024-08-31T02:29:58-04:00", "question_creation_date": "Aug 31, 2024 02:29 AM", "meta_title": "[Solved] For this discussion, we will be looking a | SolutionInn", "meta_description": "Answer of - For this discussion, we will be looking at a simple HTML file (index.htm) and an external JavaScript file (disc_3.js). | SolutionInn", "meta_keywords": "discussion,will,looking,simple,html,file,indexhtm,external,javascript,disc,3,js", "question_title_h1": "For this discussion, we will be looking at a simple HTML file (index.htm) and an external JavaScript file (disc_3.js). Open both files in your text", "question_title": "For this discussion, we will be looking at a simple HTML file", "question_title_for_js_snippet": "For this discussion, we will be looking at a simple HTML file (index htm) and an external JavaScript file (disc 3 js) Open both files in your text editor and examine their contents also open index htm in a web browser The HTML file and JavaScript file work together to allow the user to enter their favorite car makes into the textbox The addCar() function in disc 3 js then adds the car makes to an array Once the array reaches four entries, the array contents are output to a element with an ID of output In its current form, disc 3 js contains three errors having to do with arrays, loops, and if statements For this discussion, please do the following 1) Identify all three errors 2) Explain why the errors prevent the code form working 3) Provide solutions to each error Please upload your corrected JavaScript file as LASTNAME FIRSTNAME disc 3 js Content of index htm Discussion 3 Discussion 3 Favorite Cars Enter your four favorite cars into the textbox Content of disc 3 js This program uses an array to store a list of favorite car makes and then outputs the contents to an HTML page var cars Array to hold car makes (Error 1 not an array) var i 0 Index The addCar() function will add a car from the textbox to the cars array The array is output once it contains 4 entries function addCar() if (i 4) cars i input value input value i if (i 4) Error 2 assignment instead of comparison displayCars() The displayCars() function uses a for loop to loop through the cars array and output its contents to the element with ID output function displayCars() Reference the element with ID output for simpler code var output document getElementById( output ) output innerHTML Your list is for (var j 1 j cars length j ) Error 3 j should start at 0 output innerHTML cars j if (j cars length 1) output innerHTML , Backward compatible event listener if (document getElementById( submit ) addEventListener) document getElementById( submit ) addEventListener( click , addCar, false) else if (document getElementById( submit ) attachEvent) document getElementById( submit ) attachEvent( onclick , addCar) ", "question_description": "

For this discussion, we will be looking at a simple HTML file (index.htm) and an external JavaScript file (disc_3.js). Open both files in your text editor and examine their contents; also open index.htm in a web browser. The HTML file and JavaScript file work together to allow the user to enter their favorite car makes into the textbox. The addCar() function in disc_3.js then adds the car makes to an array. Once the array reaches four entries, the array contents are output to a

element with an ID of \"output\".<\/p>

In its current form, disc_3.js contains three errors having to do with arrays, loops, and if statements. For this discussion, please do the following: 1) Identify all three errors 2) Explain why the errors prevent the code form working 3) Provide solutions to each error<\/p>

Please upload your corrected JavaScript file as LASTNAME_FIRSTNAME_disc_3.js<\/p>

<\/p>

Content of index.htm:<\/p>

Discussion 3<\/title> <\/head><\/p> <p> <body> <h1>Discussion 3<\/h1> <p><b>Favorite Cars<\/b><\/p> <p> Enter your four favorite cars into the textbox. <\/p> <br\/><br\/><\/p> <p> <input type=\"text\" id=\"input\"><br\/> <input type=\"button\" id=\"submit\" value=\"Submit\"><br\/><\/p> <p> <p id=\"output\"><\/p> <br\/><\/p> <p> <script src=\"disc_3.js\"><\/script> <\/body> <\/html><\/p> <p> Content of disc_3.js:<\/p> <p>\/\/ This program uses an array to store a list of favorite car makes and then \/\/ outputs the contents to an HTML page.<\/p> <p>var cars; \/\/ Array to hold car makes (Error 1: not an array) var i = 0; \/\/ Index<\/p> <p>\/\/ The addCar() function will add a car from the textbox to the cars[] array. \/\/ The array is output once it contains 4 entries. function addCar() { if (i < 4) { cars[i] = input.value; input.value = \"\"; i++; if (i = 4) { \/\/ Error 2: assignment instead of comparison displayCars(); } } }<\/p> <p>\/\/ The displayCars() function uses a for loop to loop through the cars[] array \/\/ and output its contents to the <p> element with ID \"output\" function displayCars() { \/\/ Reference the element with ID \"output\" for simpler code var output = document.getElementById(\"output\");<\/p> <p> output.innerHTML += \"Your list is: \"; for (var j = 1; j < cars.length; j++) { \/\/ Error 3: j should start at 0 output.innerHTML += cars[j]; if (j < cars.length - 1) output.innerHTML += \", \"; } }<\/p> <p>\/\/ Backward compatible event listener if (document.getElementById(\"submit\").addEventListener) { document.getElementById(\"submit\").addEventListener(\"click\", addCar, false); } else if (document.getElementById(\"submit\").attachEvent) { document.getElementById(\"submit\").attachEvent(\"onclick\", addCar); }<\/p>", "transcribed_text": "", "related_book": { "title": "Hands On Database", "isbn": "013610827X, 978-0136108276", "edition": "1st Edition", "authors": "Steve Conger", "cover_image": "https:\/\/dsd5zvtm8ll6.cloudfront.net\/si.question.images\/book_images\/64ed8e88e05da_47840.jpg", "uri": "\/textbooks\/hands-on-database-1st-edition-9780136108276", "see_more_uri": "\/textbooks\/computer-science-beautifulsoup-2418" }, "question_posted": "2024-08-31 02:29:58", "step_by_step_answer": "The Answer is in the image, click to view ...", "students_also_viewed": [ { "url": "\/1-antonia-wants-to-buy-a-car-the-dealer-permits", "description": "1. Antonia wants to buy a car. The dealer permits her to take an automobile home to show her mother. On the way home, she gets into an accident. Is Antonia an agent for the dealer? (If she is, the...", "stars": 3 }, { "url": "\/study-help\/psychology\/2-even-the-most-classical-of-heroes-typically-do-not-1988045", "description": "2. Even the most classical of heroes typically do not go through every stage of Campbells model. Nevertheless, construct an outline of your script in which your hero goes through every stage. Even...", "stars": 3 }, { "url": "\/small-vessel-was-purchased-by-chemical", "description": "A small vessel was purchased by a chemical company for $55,000 and is to be depreciated by MACRS depreciation . When its requirements changed suddenly, the chemical company leased the vessel to an...", "stars": 3 }, { "url": "\/study-help\/questions\/novak-corp-is-authorized-to-issue-both-preferred-and-common-10111163", "description": "Novak Corp. is authorized to issue both preferred and common stock. The par value of the preferred is $50. During the first year of operations, the company had the following events and transactions...", "stars": 3 }, { "url": "\/study-help\/questions\/8d-of-the-nlra-prohibits-any-modifications-or-changes-in-2148417", "description": "8(d) of the NLRA prohibits any modifications or changes in a collective bargaining agreements provisions relating to _____ during the term of the agreement unless both parties to the agreem", "stars": 3 }, { "url": "\/study-help\/questions\/section-banswer-any-three-of-these-four-questions-20360-marks-1027570", "description": "SECTION B-Answer any THREE of these four questions [203=60 marks] QUESTION #3 3D Rigid Body Equilibrium 2 m x 6 m 3 m 3 m D 4 m F2 (350j) N B [20 marks] F = (-800k) N Figure 2 (Courtesy of Prentice...", "stars": 3 }, { "url": "\/study-help\/questions\/please-provide-your-analysis-and-arguments-case-a-haplesshospital-employs-3618155", "description": "Please Provide your analysis and arguments Case A HaplessHospital employs Dr. Frank Aterror, a surgeon who in the past has sexually assaulted female patients. Suppose that he sees a thousand patients...", "stars": 3 }, { "url": "\/study-help\/questions\/what-is-sales-enablement-and-how-it-works-how-1003858", "description": "What is Sales Enablement and how it works ? How to Scale Your Sales Team Quickly? How to do t-test in Excel Simplest way of explaining please", "stars": 3 }, { "url": "\/study-help\/questions\/explain-the-goal-of-a-denialofservice-dos-attack-how-are-999031", "description": "Explain the goal of a denial-of-service (DoS) attack. How are these attacks initiated? How can they be prevented?", "stars": 3 }, { "url": "\/study-help\/questions\/comparative-financial-statements-for-weller-corporation-a-merchandising-company-for-1001567", "description": "Comparative financial statements for Weller Corporation, a merchandising company, for the year ending December 31 appear below. The company did not issue any new common stock during the year. A total...", "stars": 3 }, { "url": "\/study-help\/business-communication-essentials\/work-with-your-instructor-to-select-and-locate-a-copy-2117952", "description": "Work with your instructor to select and locate a copy of a policy that applies to students at your school (i.e., adding\/dropping a class; using the Internet to download music; posting flyers to...", "stars": 3 }, { "url": "\/study-help\/business-communication-essentials\/how-does-the-purpose-of-a-proposals-cover-letter-or-2117948", "description": "How does the purpose of a proposals cover letter or memo differ from the purpose of the proposals summary? (Objective 3)", "stars": 3 }, { "url": "\/study-help\/business-communication-essentials\/what-is-the-inverted-pyramid-format-why-is-it-used-2117953", "description": "What is the inverted pyramid format? Why is it used when composing news releases? (Objective 6)", "stars": 3 } ], "next_back_navigation": { "previous": "\/study-help\/questions\/the-intangible-assets-and-goodwill-reported-by-crane-corporation-at-8775857", "next": "\/study-help\/questions\/in-january-2022-the-management-of-foress-corporation-a-publiclytraded-8775859" }, "breadcrumbs": [ { "name": "Study help", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers" }, { "name": "Computer Science", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers\/computer-science" }, { "name": "Databases", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/computer-science-databases" }, { "name": "For this discussion, we will be looking at a simple HTML file", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/for-this-discussion-we-will-be-looking-at-a-simple-8775858" } ], "skill_details": { "skill_id": "656", "skill_name": "Databases", "parent_id": "8" } }