I'm trying to call multiple functions at once and have them displayed on the screen. CalculateSum function is able to display correctly. The error message is quotient not defined. I've looked at CalculateQuotient function, I don't understand what I'm missing. Is there a different way to call the function?
function CalculateSum(numberOne,numberTwo) {
var sum = 0;
sum = (numberOne + numberTwo);
return sum
}
function CalculateDifference(numberOne,numberTwo) {
var difference = 0;
difference = (numberOne - numberTwo);
return difference
}
function CalculateProduct(numberOne,numberTwo) {
var product = 0;
product = (numberOne * numberTwo);
return product
}
function CalculateQuotient(numberOne,numberTwo) {
var qoutient = 0;
quotient = (numberOne / numberTwo);
return quotient
}
function Main() {
// variables for this part of the program
var numberOne = 0;
var numberTwo = 0;
var output = "";
// get value from users
numberOne = prompt("Enter first nummber");
numberTwo = prompt("Enter second number");
numberOne = Number(numberOne);
numberTwo = Number(numberTwo);
// call function and capture return value
sum = CalculateSum(numberOne, numberTwo);
difference = CalculateDifference(numberOne, numberTwo);
product = CalculateProduct(numberOne, numberTwo);
quotient = CalculateQuotient(numberOne, numberTwo);
// create output statement
output = "The sum is " + sum + ".";
output = "The difference is " + difference + ".";
output = "The product is " + product + ".";
output = "The qoutient is " + qoutient + ".";
document.write(output);
}
// We have to call our Main function explicitly or it won't work.
Main();
quotient is misspelled as qoutient when you concatenate your output string together. So the interpreter is attempting to evaluate a variable that hasn't actually been defined
The variable name is "quotient" and not this "qoutient" just change that.
Thanks