Skip to content

Instantly share code, notes, and snippets.

@itzjonas
Last active February 6, 2018 06:01
Show Gist options
  • Save itzjonas/d38677ee06c7b806feae00018ceb28f0 to your computer and use it in GitHub Desktop.
Save itzjonas/d38677ee06c7b806feae00018ceb28f0 to your computer and use it in GitHub Desktop.
Code Challenge: 2018-01-30 - https://repl.it/@itzjonas/StarTower
const starTowerNew = levels => [...Array(levels)].map((v, i) => '*'.repeat(i * 2 + 1).padStart(i + levels).padEnd(levels * 2 - 1));
console.log(starTowerNew(20));
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