Concept explainers
a.
To define addItem() function and inside this function create a variable named foodItem and store the reference of next sibling element to target event object in it.
b.
To create a variable named foodID inside the addItem function that contains value of the id attribute for foodItem.
c.
To create a variable named foodDescriptionthat contains copy of foodItem element.
d.
To create a variable named cartBox that refrence of element having ID “cart”.
e.
To create a variable named duplicateOrderand set its initial value to false.
f.
To loop through element of child nodes of cartBox and for each node find whether the ID of element node equals foodID. In case yes then increment the value of first child node of element node by 1 and set duplicateOrder to true.
g.
To check if value of duplicateOrder is still false. In case yes then create variable named OrderCount which stores span element and has text content as 1. Next add this element as first child of the foodDescription element and then add foodDescription element in cartBox.
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
New Perspectives on HTML5, CSS3, and JavaScript
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning