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));
@desinas
Copy link
Author

desinas commented Dec 19, 2017

What Went Well

  • Your code should have a buildTriangle() function
  • Your buildTriangle() function should take one argument
  • Your buildTriangle() function should build a triangle

Feedback: Your answer passed all our tests! Awesome job!

@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