I am currently taking an intro to coding class and we are working with JS. My code is good but I am missing something because for the discount outputs I always get NAN. Does anyone know why this is happening?
//Input
var orderAmount = prompt("What is the order amount?");
var contractor = prompt("Are you a contractor? yes/no?");
var employee = prompt("Are you an employee? yes/no?");
var age = prompt("How old are you?");
//Constant
var employeeDisc = .10;
var largeOrderDisc = .05;
var contractorDisc = .20;
var taxRate = .08;
var noTax = 0;
//Calculations
if (orderAmount >= 800) {
var discounta = orderAmount * largeOrderdisc;
}else {
var discounta = 0;
}
if (contractor == "yes") {
var discountc = orderAmount * contractorDisc;
}else if(contractor == "no") {
var discountc = 0;
}
if(employee == "yes") {
var discounte = orderAmount * employeeDisc;
}else if(emplyee == "no") {
var discounte = 0;
}
var discount = discountc + discounte + discounta;
var subtotal = orderAmount - discount;
if (age >= 90){
tax = subtotal * noTax;
}else {
tax = subtotal * taxRate;
}
total = subtotal - tax;
//Output
document.write("Original Price: $" + orderAmount);
document.write("Discount: $" + discount);
document.write("Subtotal: $" + orderAmount);
document.write("Tax: $" + tax);
document.write("Final Price: $" + total);
document.write("Final Price: $" + total);
Sorry about the code not compiling. It is now fixed. The issue now is that my document.write are not writing.