Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

number pyramid in 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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: vuejs scrollBehavior 
Javascript :: postgresql update json field key value 
Javascript :: javascript regex extract url from string 
Javascript :: style font size javascript 
Javascript :: simulate click jest 
Javascript :: s3 list objects in folder node js 
Javascript :: javascript change frame background 
Javascript :: reset form javascript/jquery 
Javascript :: remove duplicates from array of objects javascript 
Javascript :: send multiple files using formdata jquery 
Javascript :: navigate-to-an-anchor-on-another-page 
Javascript :: how to get array from items quantity 
Javascript :: js every x seconds 
Javascript :: getters in nuxt vuex acccessing 
Javascript :: how to return ascending array using for loop in js 
Javascript :: how to clear js var 
Javascript :: generate random string javascript 
Javascript :: two decimal places in javascript 
Javascript :: js close window 
Javascript :: moment use in angular 
Javascript :: eliminar el ultimo caracter de un string javascript 
Javascript :: select add option javascript 
Javascript :: difference between devDependency and dependency 
Javascript :: easy way to create infinite loop in javascript 
Javascript :: how to calculate distance between two points in javascript 
Javascript :: react image compression 
Javascript :: makes number negative javascript 
Javascript :: how to reload a module in node.js 
Javascript :: Error: `createStackNavigator()` has been moved to `react-navigation-stack`. 
Javascript :: in select option how to make one default in angular 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =