Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Programming Quiz: Build A Triangle (5-3)
- */
- //functions
- //Hoisting
- //Loops
- // 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.
- // check length value
- // build a loop that builds lines of * that equates to length-1 till length-1 >= 0
- function buildTriangle(length){
- var z = "";
- for(x=1; x<= length; x++){
- z += makeLine(x);
- }
- return z;
- }
- // test your code by uncommenting the following line
- console.log(buildTriangle(10));
Add Comment
Please, Sign In to add comment