Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Reverse pyramid star pattern in JavaScript

// Reverse pyramid Or Triangle star pattern in JavaScript
let numberPyramid = 5;
let stringPyramid = '';
for(let i=1; i<=numberPyramid; i++){
  for(let j=1; j<=i -1; j++){
    stringPyramid += ' ';
  }
  for(let k=i; k<=2 * numberPyramid -i; k++){
    stringPyramid += '*';
  }
  stringPyramid += '
';
}
console.log(stringPyramid);
 
PREVIOUS NEXT
Tagged: #Reverse #pyramid #star #pattern #JavaScript
ADD COMMENT
Topic
Name
2+1 =