can someone please help me with this simple javascript code:
var labor;
labor=prompt("Enter your labor cost",""
;
var material;
material=prompt("Enter your material cost",""
;
var cost;
cost=labor + material;
{
alert ("Your total cost is " + cost + "."
;
}
the problem is the 6th line...instead of actually adding the numbers that the user inputs (labor and material), that line just puts the two numbers together. So for example if the user enters $4,000 for labor cost and $5,000 for material cost, the total cost is 40005000 instead of $9,000.
Please help!
var labor;
labor=prompt("Enter your labor cost",""
var material;
material=prompt("Enter your material cost",""
var cost;
cost=labor + material;
{
alert ("Your total cost is " + cost + "."
}
the problem is the 6th line...instead of actually adding the numbers that the user inputs (labor and material), that line just puts the two numbers together. So for example if the user enters $4,000 for labor cost and $5,000 for material cost, the total cost is 40005000 instead of $9,000.
Please help!