HTML
<template>
<lightning-card title="Random Number Example">
<div class="slds-m-around_medium">
<lightning-button label="Generate Random Number" onclick={getRandomNumber}></lightning-button>
<p>The random number is {randomNumber}</p>
</div>
</lightning-card>
</template>
Java Script
import { LightningElement } from 'lwc';
export default class RandomNumberExample extends LightningElement {
randomNumber;
getRandomNumber() {
this.randomNumber = Math.floor(Math.random() * 10) + 1;
return this.randomNumber;
}
}
Video
Video does not exists.