Skip to content

Instantly share code, notes, and snippets.

@youngjinmo
Last active November 13, 2018 15:11
Show Gist options
  • Save youngjinmo/759d1b01b54a330c1a7ee3cb6468d312 to your computer and use it in GitHub Desktop.
Save youngjinmo/759d1b01b54a330c1a7ee3cb6468d312 to your computer and use it in GitHub Desktop.
Passed second answer that quiz 5-3 in Intro to JavaScript at Udacity.
/*
* 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(width){
var triangle = "";
for(var i=1; i<=width; i++){
triangle += makeLine(i);
}
return triangle;
}
// test your code by uncommenting the following line
console.log(buildTriangle(10));
@youngjinmo
Copy link
Author

Feedback

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!

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