how to log a dimand shape in javascript code example
Example: how to log a dimand shape in javascript
function createDimondShape(size){
for(var i=1;i<=size;i++){
for(var s=size-1;s>=i;s--){
process.stdout.write(" ");
}
for(var j=1;j<=i;j++){
process.stdout.write("* ")
}
console.log();
}
if(i==size+1){
for(var i=1;i<=size-1;i++){
for(var s=1;s<=i;s++){
process.stdout.write(" ");
}
for(j=i;j<=size-1;j++){
process.stdout.write("* ");
}
console.log();
}
}
}
createDimondShape(9);