Day 51: Pattern using loops of 100DaysCodingChallenge

Hello all, 

#day51 

Day51 

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


Inverted 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 half(a) {
  for (let i = a; i >= 0; i--) {
    for (let j = 0; j < i; j++) {
      string += "* ";
    }
    string += "\n";
  }
  console.log(string);
}
half(a);

Output :     

 





Happy Coding:)

Thank you...     

Comments

Popular posts from this blog

Day 100: Date Time to Number of 100DaysCodingChallenge

Day 64: Pattern using loops of 100DaysCodingChallenge

Day 20: Positive Number of 100DaysCodingChallenge