jeudi 22 juillet 2021

How to print sideways in Javascript?

I want to print a triangl. I am getting my expected result but it's printing in consecutive lines. I want to print the "*" sideways for every for loop's output. How do I do it?

Code:

let a,b,c;
a = 5;
b = 1;
while(b <= a){
  for(c=1;c<=b;c++){
    console.log('*');
  }
  b++;
  console.log('\n')
}

Output

enter image description here

Aucun commentaire:

Enregistrer un commentaire