HTML
<template>
<button onclick={handleLoop}>Loop 10 Times</button>
<p>{loopOutput}</p>
</template>
Java Script
import { LightningElement } from 'lwc';
export default class BreakExample extends LightningElement {
loopOutput = '';
handleLoop() {
for (let i = 0; i < 10; i++) {
if (i === 3) {
break;
}
this.loopOutput += `The number is ${i}<br>`;
}
}
}
Video
Video does not exists.