Last active
February 6, 2018 06:01
-
-
Save itzjonas/d38677ee06c7b806feae00018ceb28f0 to your computer and use it in GitHub Desktop.
Code Challenge: 2018-01-30 - https://repl.it/@itzjonas/StarTower
This file contains hidden or 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
const starTowerNew = levels => [...Array(levels)].map((v, i) => '*'.repeat(i * 2 + 1).padStart(i + levels).padEnd(levels * 2 - 1)); | |
console.log(starTowerNew(20)); |
This file contains hidden or 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
function starTowerOld(levels) { | |
const arr = []; | |
for(let i = 0; i < levels; i++){ | |
arr.push('*'.repeat(i * 2 + 1).padStart(i + levels).padEnd(levels * 2 - 1)); | |
} | |
return arr; | |
} | |
console.log(starTowerOld(20)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment