Class Example Javascript

Class Example Javascript

by sunil puvvada

HTML

<h1 id="result">

</h1>
<h1 id="CLASS">
</h1>
</h1>

JavaScript

var CalculatorOperations = {
  add: function(value1, value2) {
    return value1 + value2;
  },
  subtract: function(value1, value2) {
    return value1 - value2;
  },
  multiply: function(value1, value2) {
    return value1 * value2;
  },
  divide: function(value1, value2) {
    return value1 / value2;
  },
  generateRandomNumber: function() {
    return (Math.random() * 1000) | 0;
  },
};

var value = CalculatorOperations.add(1,3);
$("#result").html(value);

var otherExam = function(){
return{
 add: function(value1, value2) {
    return value1 + value2;
  },
  subtract: function(value1, value2) {
    return value1 - value2;
  }
}
};

var value = new otherExam();
var exceu = value.add(2,3);

$("#CLASS").html(exceu);