DEV Community

Amit Prajapati
Amit Prajapati

Posted on

Write the program to show the tringle ?

let space = '';
let n = '';
let m = '';
for(let i=1;i<=6;i++){
    for(let j=6;j>=i;j--){
      space = space + ' - ';
    }
    for(let z=1;z<=i;z++){
        n = n + ` ${z} `
    }
    for(let k=i-1;k>=1;k--){
        m = m + ` ${k} `
    }
    console.log(space+n+m)
    n = '';
    space = '';
    m = '';
}
Enter fullscreen mode Exit fullscreen mode

Image description

Top comments (0)