Last active
September 28, 2022 06:24
-
-
Save Nasah-Kuma/da5187cc3b3017582edcba724b85668d to your computer and use it in GitHub Desktop.
Hackerrank Challenge: https://www.hackerrank.com/challenges/staircase/problem?isFullScreen=true
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
/* | |
* Complete the 'staircase' function below. | |
* | |
* The function accepts INTEGER n as parameter. | |
*/ | |
function staircase(n) { | |
// Write your code here | |
let newString = ''; | |
let j = n-1; | |
let i = n; | |
while (i>0) { | |
newString += '#'; | |
console.log(' '.repeat(j)+newString); | |
i--; | |
j--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment