HTML
<template>
<lightning-card>
<button onclick={handleLoop}>Sum of the first 10 integers</button>
<p>Sum: {sum}</p>
</lightning-card>
</template>
Java Script
import { LightningElement } from 'lwc';
export default class WhileLoopExample extends LightningElement {
i=1;
sum = 0;
handleLoop() {
while (this.i < 10) {
this.sum += this.i;
this.i++;
}
}
}
Video
Video does not exists.