Skip to content

Instantly share code, notes, and snippets.

@Risyandi
Created November 14, 2018 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Risyandi/9b7067b64477346abf574d5c1ed57aa9 to your computer and use it in GitHub Desktop.
Save Risyandi/9b7067b64477346abf574d5c1ed57aa9 to your computer and use it in GitHub Desktop.
This is assignment for Asterik Pyramid Program using javascript
function asterikPyramid(rows, symbol1, symbol2) {
for (let index = 0; index < rows; index++) {
// console.log(index, "index");
// this is step one to print empty spaces
var space = "";
for (let indexj = 0; indexj < (rows - index - 1); indexj++) {
// console.log(indexj, "indexj");
space += symbol2;
}
// this is step two to print asterik
var asterik = "";
for (let indexk = 0; indexk < (2 * index); indexk++) {
// console.log(indexk, "indexk");
asterik += symbol1;
}
// print asterik to console
console.log(space + asterik);
}
}
// call function
asterikPyramid(6, "*", " ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment