HTML
<template>
<lightning-card title="Simple Addition">
<div class ='slds-var-m-around_medium'>
<lightning-input type='number' label="First Number" onkeyup={firstNumberHandler}></lightning-input>
<lightning-input type='number' label="Second Number" onkeyup={secondNumberHandler}></lightning-input>
<div class="slds-var-m-around_medium"><b>Sum:</b> {Sum}</div>
</div>
</lightning-card>
</template>
JavaScript
import SumEPT from '@salesforce/schema/LightningUsageByPageMetrics.SumEPT';
import { LightningElement } from 'lwc';
export default class Calculater extends LightningElement {
firstNumber = 0; secondNumber = 0;
firstNumberHandler(event){
this.firstNumber = Number(event.target.value);
}
secondNumberHandler(event){
this.secondNumber = Number(event.target.value);
}
get Sum() {
const sum = this.firstNumber + this.secondNumber;
return `${this.firstNumber} + ${this.secondNumber} = ${sum}`;
}
}