Answer:
Step-by-step explanation:
the answer is also in the question. The loop is used to control the number of program execution. So in order not to run forever, the loop should be included inside the loop brackets. Then you can restructure the code as done below.
var numItems = promptNum("How many items?");
var total = 0;
var itemPrice=0;
while (numItems > 0){
itemPrice = promptNum("Enter next item price");
total = total + itemPrice;
numItems = numItems - 1;
}
console.log("The total is" + total);
The value to be displayed will be the total of the item prices inputted.