Advertisement
Guest User

Quiz: Build a Triangle (5-3)

a guest
Dec 11th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Programming Quiz: Build A Triangle (5-3)
  3.  */
  4.  
  5. // creates a line of * for a given length
  6. function makeLine(length) {
  7.     var line = "";
  8.     for (var j = 1; j <= length; j++) {
  9.         line += "* ";
  10.     }
  11.     return line + "\n";
  12. }
  13.  
  14. // your code goes here.  Make sure you call makeLine() in your own code.
  15. function buildTriangle(height) {
  16.     for (var lenght = 1 ; lenght<=height ; lenght++) {
  17.         console.log(makeLine(lenght));
  18.     }
  19. }
  20.  
  21.  
  22. // test your code by uncommenting the following line
  23. console.log(buildTriangle(10));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement