Created
December 16, 2018 21:43
-
-
Save Luke-Rogerson/d3bab27e4ac54536a1161ca42dc3c4b4 to your computer and use it in GitHub Desktop.
Write a function that accepts a positive number N. The function should console log a step shape with N levels using the # character. Make sure the step has spaces on the right hand side!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --- Examples | |
// steps(2) | |
// '# ' | |
// '##' | |
// steps(3) | |
// '# ' | |
// '## ' | |
// '###' | |
// steps(4) | |
// '# ' | |
// '## ' | |
// '### ' | |
// '####' | |
function steps(n, i = 1) { | |
if (i > n) return; | |
console.log('#'.repeat(i) + ' '.repeat(n - i)); | |
steps(n, i + 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment