New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN: 9781305503922
Author: Patrick M. Carey
Publisher: Cengage Learning
bartleby

Concept explainers

Question
Book Icon
Chapter 12, Problem 5CP2

a.

Program Plan Intro

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.

Program Plan Intro

To create a variable named foodID inside the addItem function that contains value of the id attribute for foodItem.

c.

Program Plan Intro

To create a variable named foodDescriptionthat contains copy of foodItem element.

d.

Program Plan Intro

To create a variable named cartBox that refrence of element having ID “cart”.

e.

Program Plan Intro

To create a variable named duplicateOrderand set its initial value to false.

f.

Program Plan Intro

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.

Program Plan Intro

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.

Blurred answer