We are going to display an inverted population pyramid in the browser. Using a prompt(), ask for a number between 2 and 9 (alert() if the number is out of the range and ask again for the number) and, so far, display half of the pyramid using a loop
function pyramid(n) { for (let i = 1; i <= n; i++) { let str = '' for (let j = 1; j <= (n - i); j++) { str += '.' } for (let k = 1; k <= i; k++) { str += '#' } console.log(str) } } pyramid(5)