<template>
<lightning-card title="*******************HDFC Bank********************" >
<p><b><u>Fixed Deposit Calculator</u></b></p>
<lightning-input type="number" label="Enter the Prinipal" onchange={principal}></lightning-input>
<lightning-input type="number" label="Enter the year of investment" onchange={year}></lightning-input>
<lightning-input type="number" label="Enter the rate of interest" onchange={interest}></lightning-input>
<lightning-button-group>
<lightning-button label="Calculate" onclick={calculate}></lightning-button>
<lightning-button label="Clear" onclick={clear}></lightning-button>
</lightning-button-group>
<p> The Maturity amount is = {maturityamount} </p>
</lightning-card>
</template>
this is my JS
import { LightningElement,track} from 'lwc';
export default class HdfcFixedDepositCalculator extends LightningElement {
principal;
interest;
year;
@track maturityamount;
principal(event){
this.principal=parseInt(event.target.value);
}
year(event){
this.year=parseInt(event.target.value);
}
interest(event){
this.interest=parseInt(event.target.value);
}
calculate(){
this.maturityamount=this.principal*this.interest*this.year/100;
}
}
principal
,year
andinterest
, that is not correct. For the change event handler, rename them toonPrincipalChange()
and so on. Then finally you would need to add a null check oncalculate()
method.