1 const numbers = [3, 6, 12, 24, 48, 63];
2 let text = "";
3
4 numbers.forEach((value, index) => {
5 text += value + "<br>";
6 })
Foreach Loop Usage in HTML
1<!DOCTYPE html>
2<html>
3<body>
4<h2>JavaScript Array.forEach()</h2>
5<p id="demo"></p>
6
7<script>
8 const numbers = [3, 6, 12, 24, 48, 63];
9 let text = "";
10
11 numbers.forEach((value, index) => {
12 text += value + "<br>";
13 })
14 document.getElementById("demo").innerHTML = text;
15</script>
16
17</body>
18</html>