var Maths = {
addNumbers: function(one, two) {
return one + two;
},
subNumbers: function(one, two) {
return one - two;
},
mulNumbers: function(one, two) {
return one * two;
},
divNumbers: function(one, two) {
if (two != 0)
return one / two;
else
return "Division failed. Denominator cannot be Zero";
}
}
function mathOperations() {
alert(
"Addition of 10 and 20 is " + Maths.addNumbers(10, 20) + "\n\n" +
"Substraction of 10 and 20 is " + Maths.subNumbers(10, 20) + "\n\n" +
"Multiplication of 10 and 20 is " + Maths.mulNumbers(10, 20) + "\n\n" +
"Division of 10 and 20 is " + Maths.divNumbers(10, 20)
);
}
Output:

Like this:
Like Loading...