const genA= n => Array.from({length:n}).map((e,i) => i+1) const genB = n => genA(n).join('').padStart(5,'*')+genA(n).reverse().slice(1).join('').padEnd(4, '*') Array.apply(null, {length:5}).map((e, i) => genB(i+1)).forEach(e => console.log(e))