for each loop in LWc\ code example
Example 1: for:each in lwc js
<template>
<lightning-card title="Account List using for:each" icon-name="custom:custom63">
<div class="slds-m-around_medium">
<template if:true={accounts.data}>
<template for:each={accounts.data} for:item="acc">
<p key={acc.Id}>{acc.Name}</p>
</template>
</template>
<template if:true={accounts.error}>
{accounts.error}
</template>
</div>
</lightning-card>
</template>
Example 2: for:each in lwc js
<template for:each={lstAccounts} for:item="acc">
<p key={acc.Id} style="display:inline">
<lightning-badge label={acc.Name}></lightning-badge>
</p>
</template>