HTML
<template>
<p>{number1} + {number2} = {result}</p>
<button onclick={handleAddition}>Add</button>
<button onclick={handleSubtraction}>Subtract</button>
<button onclick={handleMultiplication}>Multiply</button>
<button onclick={handleDivision}>Divide</button>
<button onclick={handleModulus}>Modulus</button>
<button onclick={handleIncrement}>Increment</button>
<button onclick={handleDecrement}>Decrement</button>
</template>
Java Script
import { LightningElement } from 'lwc';
export default class OperatorExample extends LightningElement {
number1 = 5;
number2 = 10;
result = null;
handleAddition() {
this.result = this.number1 + this.number2;
}
handleSubtraction() {
this.result = this.number1 - this.number2;
}
handleMultiplication() {
this.result = this.number1 * this.number2;
}
handleDivision() {
this.result = this.number1 / this.number2;
}
handleModulus() {
this.result = this.number1 % this.number2;
}
handleIncrement() {
this.number1++;
}
handleDecrement() {
this.number1--;
}
}
Video
Video does not exists.