Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
Comment

pyramid javascript

function generatePyramid() {
    var totalNumberofRows = 5;
    var output = '';
    for (var i = 1; i <= totalNumberofRows; i++) {
        for (var j = 1; j <= i; j++) {
            output += j + '  ';
        }
        console.log(output);
        output = '';
    }
} generatePyramid();
Comment

PREVIOUS NEXT
Code Example
Javascript :: get current time in javascript 
Javascript :: scroll to div jquery 
Javascript :: javascript fill array 
Javascript :: wait javascript 
Javascript :: style before and after javascript 
Javascript :: how to check div is display:none or block in javascript 
Javascript :: create array javascript numbers 
Javascript :: how to cheack if a number is an integer or float in javascript 
Javascript :: how to add a shadow react native 
Javascript :: get element by tag name 
Javascript :: make keystore 
Javascript :: remove element from array in an immutable way 
Javascript :: get 5 months after date in javascript 
Javascript :: lazy loading pagination react npm 
Javascript :: js array sort 
Javascript :: form.select react bootstrap 
Javascript :: localstorage javascript 
Javascript :: js add style to each class 
Javascript :: for each python json 
Javascript :: pipe of date angular 
Javascript :: iterate through list js 
Javascript :: javascript move last array element to first 
Javascript :: angular new formcontrol default value 
Javascript :: how to create infinite loop in javascript 
Javascript :: javascript string array sort alphabetically 
Javascript :: javascript radio button onchange 
Javascript :: print hello world in javascript 
Javascript :: padstart and padend javascript 
Javascript :: react date picker disable past dates 
Javascript :: how to always run validators mongoose 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =