DEV Community

Anjali Gurjar
Anjali Gurjar

Posted on

Pattern Print

// function start(n){

// for(let i=1;i<=n;i++){
// console.log("* " .repeat(i))
// }
// }
// start(5)

// function halfPyramid(n) {
// for (let i = 1; i <= n; i++) {
// console.log("* ".repeat(i));
// }
// }
// function fullPyramid(n) {
// for (let i = n; i >=1; i--) {
// console.log(" ".repeat(n - i) + "* ".repeat(i));
// }
// }
// fullPyramid(5);

// function up(n){
// for(let i=1; i<=n;i++){
// console.log(" ".repeat(n-i)+"* ".repeat(i) )
// }
// }

// up(5)

function up(n){
// for(let i=1; i<=n;i++){
// if(i===1 || i===n){
// console.log("* ".repeat(n) )

// }
// else{
// console.log("* " +" ".repeat(n-2) + "*" )
// }

// }
// }
for(let i=1; i<=n;i++){
console.log(" * ".repeat(n))
}

// for(let i=1; i<=n;i++){
// if(i===1 || i===n){
// console.log(" ".repeat(n-i)+"* ".repeat(i) )

// }
// else{
// console.log(" ".repeat(n-i)+"*"+" ".repeat(i-2)+" *" )

// }
}
up(5)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay