Guest User

Untitled

a guest
May 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. /*
  2. * Programming Quiz: Build A Triangle (5-3)
  3. */
  4. //functions
  5. //Hoisting
  6. //Loops
  7.  
  8.  
  9. // creates a line of * for a given length
  10. function makeLine(length) {
  11. var line = "";
  12. for (var j = 1; j <= length; j++) {
  13. line += "* ";
  14. }
  15. return line + "\n";
  16. }
  17.  
  18. // your code goes here. Make sure you call makeLine() in your own code.
  19. // check length value
  20.  
  21. // build a loop that builds lines of * that equates to length-1 till length-1 >= 0
  22. function buildTriangle(length){
  23. var z = "";
  24. for(x=1; x<= length; x++){
  25. z += makeLine(x);
  26. }
  27. return z;
  28. }
  29.  
  30. // test your code by uncommenting the following line
  31. console.log(buildTriangle(10));
Add Comment
Please, Sign In to add comment