Skip to content

Instantly share code, notes, and snippets.

@desinas
Last active March 18, 2023 17:19
Show Gist options
  • Save desinas/b5035e10897586b2c596607d52fb13e3 to your computer and use it in GitHub Desktop.
Save desinas/b5035e10897586b2c596607d52fb13e3 to your computer and use it in GitHub Desktop.
Build a triangle Quiz (5-3) of Udacity FEWD
/*
* Programming Quiz: Build A Triangle (5-3)
*/
// creates a line of * for a given length
function makeLine(length) {
var line = "";
for (var j = 1; j <= length; j++) {
line += "* ";
}
return line + "\n";
}
// your code goes here. Make sure you call makeLine() in your own code.
function buildTriangle(height) {
var starTriangle = "";
for (var k = 1; k <= height; k++) {
starTriangle += makeLine(k);
}
return starTriangle;
}
// test your code by uncommenting the following line
console.log(buildTriangle(10));
@MuhammadMahmoudAli
Copy link

thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment