Create a function called totalSales(). The function will use a loop to ask the user to enter amounts until they enter the word "done." The body of the loop will add the amount of input to a variable called totalSales. When the loop ends, the function should display the value of totalSales in the warning.
Here is what I have ...
function totalSales()
{
var x = prompt("Enter numeric until done")
var amount="";
var totalSales=0;
while(x!=="done") {
x = prompt("Enter numeric until done")
if(x==="done")
{
alert(totalSales += amount);
}
}
}
My onclick event handler works, but I'm not sure how to add an unknown number to the variable. I can't get it to add instead of concatenation.
source
share