Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
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 :: javascript distance math 
Javascript :: number to binary javascript 
Javascript :: formdata to json 
Javascript :: package json add git repo 
Javascript :: style before javascript 
Javascript :: react native open link in browser 
Javascript :: generate a sequence numbers between a range javascript 
Javascript :: get the difference between two dates js 
Javascript :: javascript console output 
Javascript :: flutter circularprogressindicator 
Javascript :: javascript paragraph count 
Javascript :: map with promise.all 
Javascript :: javascript backticks 
Javascript :: javascript create a function that counts the number of syllables a word has. each syllable is separated with a dash -. 
Javascript :: ascending and descending val in array using js 
Javascript :: variable key name js 
Javascript :: local storage javascript 
Javascript :: code for adding new elements in javascriipt js 
Javascript :: today in moment 
Javascript :: how to change background image for a webpage 
Javascript :: how to iterate through an array in javascript 
Javascript :: how to go to next page on button click js 
Javascript :: js delete all array items 
Javascript :: infinite loop javascript 
Javascript :: express limit based on ip 
Javascript :: package.json tilde vs caret 
Javascript :: how to iterate object inside object in javascript 
Javascript :: javascript set checkbox checked based on value 
Javascript :: jquery toggle input checkbox 
Javascript :: how to send static file in express 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =