Answers for "make pyramid in js with given number and value"

19

number pyramid javascript

// Display pyramid of number using JavaScript
function pyramid(n) {
   for (let i = 1; i <= n; i++) {
      let str = ' '.repeat(n - i);
      let str2 = '*'.repeat(i * 2 - 1);
      console.log(str + str2 + str);
   }
}

pyramid(5);
Posted by: Guest on January-11-2022

Code answers related to "make pyramid in js with given number and value"

Code answers related to "Javascript"

Browse Popular Code Answers by Language