Day 49: Pattern using loops of 100DaysCodingChallenge

Hello all, 

#day49 

Day49 

Today's my task was to Print the below Pattern using loops.


Half Pyramid Star Pattern

*
* *
* * *
* * * *
* * * * *


I have started the 100 days of coding challenge to improve my programming skills..

Code : 

let a = prompt("Enter a number : ");
let string = "";
function full(a) {
  let k = 0;
  for (let i = 0; i < a; i++) {
    //console.log('j1', a - i);
    for (let j = 2*(a-i); j >= 0 ; j--) {
      //console.log('j1', j);
      string += " ";
    }
    //console.log('j2', i - k);
    for (let j = 2*(i - k); j >= 0 ; j--) {
//console.log('j2', j);
      string += "* ";
    }
    string += "\n";
  }
  console.log(string);
}
full(a);

Output :     

 








Happy Coding:)

Thank you...     

Comments

Popular posts from this blog

Day 7: Square or Power Integer Numbers of 100DaysCodingChallenge

Day 55: Pattern using loops of 100DaysCodingChallenge

Day 45: Pattern using loops of 100DaysCodingChallenge