EXERCISE · AlgoCasts

Pyramid

Write a function that accepts a positive number N. The function should console log a pyramid shape with N levels using the # character.

4 testsAlgoCastsGPL-3.01 alternateexercise 10 of 26

Directions

Directions

Write a function that accepts a positive number N. The function should console log a pyramid shape with N levels using the # character. Make sure the pyramid has spaces on both the left *and* right hand sides

Examples#

JS
pyramid(1)    '#'pyramid(2)    ' # '    '###'pyramid(3)    '  #  '    ' ### '    '#####'

Try it first#

Copy the stub, make the 4 tests pass on your machine, then open the solution. The reveal is remembered per page in this browser.

JSexercises/pyramid/index.js
function pyramid(n) {} module.exports = pyramid;

See also