jeudi 20 août 2020

How do we print pattern like this in JavaScript in console and not with document.write?

*
*#
*#*
*#*#
*#*#*

I tried this but it' not working

For(let i = 1; i <= 5: i++) {
    for (let j = 1; j <= i; j++) {
      if (j % 2 == 0) {
        console.log("#".repeat(j)
        }
        else {
          console.log("i".repeat(i)
          }
        }
      }

Aucun commentaire:

Enregistrer un commentaire