Can someone explain this javascript code

I created some code to print a rectangle I followed a video but I do not get the logic can someone explain?

HTML (I get this)

    <label id="myShape"></label>
    <script src="script.js"></script>

JS (I do not get this)

let symbol = window.prompt("Enter a symbol: ");
let rows = window.prompt("Enter the number of rows you want: ");
let collums = window.prompt("Enter the collums you want: ");



for (let a = 0; a <= rows; a++) {
    for (let j = 0; j <= collums; j++) {
        document.getElementById("myShape").innerHTML += symbol;
    }
    document.getElementById("myShape").innerHTML += "<br>";
}

A rectangle is made up of a certain number of rows and a certain number of columns.
So once you have these two pieces of information, you can loop around (by row and column) and print one symbol per (row,column) value.

Try to add some console.log statements to print the value of a and j and you can see what I mean.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.