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

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 :: split string based on length in javascript 
Javascript :: filter out undefined from object javascript 
Javascript :: how to get video duration in javascript 
Javascript :: ubuntu 18.04 nodejs insatll 
Javascript :: why is my deleteOne mongoose middleware not working 
Javascript :: javascript test if string starts with alphabet 
Javascript :: js Float32Array to percentage 
Javascript :: for in loop javascript 
Javascript :: convert string to camel case 
Javascript :: convert date to string javascript 
Javascript :: find inside iframe jquery 
Javascript :: How to use body-parser package in using npm 
Javascript :: deserialize json jquery 
Javascript :: js check if div have another div 
Javascript :: javascript get date 
Javascript :: js string slicing 
Javascript :: json placholder 
Javascript :: regular expression for email validation 
Javascript :: how to click on the datepicker date in jquery 
Javascript :: add tab to textarea 
Javascript :: Repeat a String Repeat a String 
Javascript :: generate random string react 
Javascript :: javascript string to variable 
Javascript :: async constructor javascript 
Javascript :: updateone mongoose example 
Javascript :: react native images 
Javascript :: how to access router from the store vue 
Javascript :: quotation marks javascript 
Javascript :: Disable click for specific elements javascript 
Javascript :: flutter intl currency 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =