Quick actions

cmd+k|ctrl+k

Navigation

Languages

complete_number-rhombus_structure(incomplete)

Snippet info

Language

JavaScript

Visibility

public

Author

codewithsyahda

Created

2020-07-29T04:59:32Z

Updated

2020-07-29T08:48:43Z

let i, j, k, n, m;
let rows = 11;
let s = '';
let l = 1;
let rowsSecOne = parseInt((rows/2 + (rows%2)));
let rowsSecTwo = parseInt(rows/2);
for(i = 1; i <= rows; ++i){
    m = parseInt(l/2 + (l%2));
    n = i;
    if(i <= rowsSecOne){ // First Non-Inverted Pyramid Section
        for(j = i; j < rowsSecOne; ++j){ // j = 2;
            s+='  ';
        }
        for(k = 1; k <= l; ++k){ 
            if(k <= m){
                s+=n + ' ';
                n+=1;
                if(k === m){
                    n-=1;
                }
            } else {
                n-=1;
                s+=n + ' ';
            }
        }
    } else{ // Second Inverted Pyramid Section
        
    }
    console.log(s);
    s='';
    l+=2;
}
INFO