Question 6 of 38

You are writing a JavaScript program for Contoso Suites that will output HTML.

You need to output each room type on a new line using the correct method.

You create the following code for the function. Line numbers are included for reference only.

You need to insert the correct code at Line 9. Which line should you use?

    Correct Answer: B

    To correctly output each room type on a new line in the HTML paragraph element with id 'para', you need to append each room type to the current inner HTML of the 'para' element and also include the existing content of 'para'. Therefore, option B is correct as it appends the current room and the existing inner HTML to 'para', ensuring each room type is displayed on a new line.

Question 7 of 38

DRAG DROP -

You are creating a web page that requests a username.

You create the following HTML form:

You need to write a function that retrieves the username from the form.

How should you complete the code? To answer, drag the appropriate code segments to the correct locations. Each function may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Select and Place:

    Correct Answer:

    References: https://www.w3schools.com/jsref/coll_doc_forms.asp

Question 8 of 38

DRAG DROP -

You are using JavaScript to create a calculator.

You create the following HTML. Line numbers are included for reference only.

You must create a function named add() that adds the values in the a and b input elements and displays the result in the result input element.

You define the following function in JavaScript:

function add() {

}

You need to complete the body of the function.

Which three code segments should you use to develop the solution? To answer, move the appropriate code segments from the list of code segments to the answer area and arrange them in the correct order.

NOTE: Each correct selection is worth one point.

Select and Place:

    Correct Answer:

    References: https://www.w3schools.com/jsref/jsref_eval.asp

Question 9 of 38

HOTSPOT -

For each of the following segments, select Yes if the statement is true. Otherwise, select No.

NOTE: Each correct selection is worth one point.

Hot Area:

    Correct Answer:

    References: https://www.w3schools.com/tags/ref_httpmethods.asp

Question 10 of 38

You are creating a web page that allows customers to choose how hot their spice is. If they choose spicy, a warning should be displayed.

You create the following form. Line numbers are included for reference only.

You create the following JavaScript code to display the warning.

When you choose spicy and click Order, the warning fails to display.

You need to solve this problem.

What should you do?

    Correct Answer: D

    The issue lies in how the selected value from the dropdown is being accessed in the JavaScript function. In line 10, 'option' is assigned the entire select element rather than its value. To get the value of the selected option, you need to access the 'value' property of the select element. Changing line 10 to 'var option = document.forms.orderForm["heatIndex"].value;' correctly assigns the selected value to 'option', thus ensuring that the 'if' condition on line 11 can properly check if the value is 'Spicy' and display the alert accordingly.