I make a simple calculator using javascript. I am providing those code below. But the problem is when i run those code. i saw a undefined output. I dont know why that text is showing. I want to remove that.
function addition(x, y) {
var sum = x + y;
document.write("Addition of two number is : " + sum);
}
function substract(x, y) {
var sub = x - y;
document.write("Subtraction of two number is : " + sub);
}
function multiply(x, y) {
var multiply = x * y;
document.write("Multipication of two number is : " + multiply);
}
function division(x, y) {
var division = x / y;
document.write("Division of two number is : " + division);
}
var x = parseInt(prompt("Enter the first number : "));
var y = parseInt(prompt("Enter the second number : "));
var operator = prompt("Enter the operator : ");
if (operator == "+") {
document.write(addition(x, y));
} else if (operator == "-") {
document.write(substract(x, y));
} else if (operator == "*") {
document.write(multiply(x, y));
} else if (operator == "/") {
document.write(division(x, y));
} else {
document.write("Invalid Operator. Please choose operator between +,-,* or /. <br> Thanks for using our calculator. ");
}