Building a Pyramid

var prystring = function(char, num){
let string = '\n'
for (let i = 1 ; i <= num; i++){
for(let j = num; j > i; j--){
string += " "
}
for(let k = 0; k < i * 2 -1; k++){
string += `${char}`
}
for(let j = num; j > i; j--){
string += " "
}
string += "\n"
}
console.log(string)
}

prystring('*',5)
'
*
***
*****
*******
*********
'
var strings = function(char, num){
let string = '\n'
for (let i = 0 ; i < num; i++){
for(let j = 0; j < i; j++){
string += " "
}
for(let k = 0; k < 2 * (num-i) -1; k++){
string += `${char}`
}
string += "\n"
}
console.log(string)
}

strings('*',5)
'
*********
*******
*****
***
*
'

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store