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 sleep function 
Javascript :: node js get input from console 
Javascript :: web3.js get balance 
Javascript :: jquery $(...)..each() is not a function 
Javascript :: regex for counting characters 
Javascript :: move dom element to another parent 
Javascript :: reset form function javascript 
Javascript :: subtract two date javascript 
Javascript :: moment js year only 
Javascript :: change padding javascript 
Javascript :: get current date 
Javascript :: react-geocode 
Javascript :: adding event listener keypress event in javascript 
Javascript :: jquery get multiple input values by name 
Javascript :: jquery on load 
Javascript :: javascript dataurl to blob 
Javascript :: print json pretty linux 
Javascript :: Use multiple conditional operators in the checkSign function to check if a number is positive, negative or zero. The function should return "positive", "negative" or "zero". 
Javascript :: exit extension from chrome javascript 
Javascript :: character limit regex 
Javascript :: loop through an array in javascript 
Javascript :: select add option js 
Javascript :: JavaScript - The first word of a string 
Javascript :: create infinite loop using for loop in javascript 
Javascript :: replace backward slash in javascript 
Javascript :: discord.js set activity 
Javascript :: search if value exists in object javascript 
Javascript :: route parammap subscribe angular 9 
Javascript :: how to disable react in jsx scope eslint 
Javascript :: adding new sass version 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =