A little help with js

// creates a line of * for a given length
function makeLine(length) {
    var line = "";
  for (var j = 1; j <= length; j++) {
    line += "* "
  }
  return line + "\n";
}

i have to create a functione buildTriangle with:

“will need to call this makeLine() function in buildTriangle().”

and output will be:

* 
* * 
* * * 
* * * * 
* * * * * 
* * * * * * 
* * * * * * * 
* * * * * * * * 
* * * * * * * * * 
* * * * * * * * * *

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

function makeLine(length) {
    var line = "";
    var next = "\n";
  for ( let j = 1; j <= length; j++ ) {
    line += "\n";
    for ( let k = 1; k <= j; k++ ) {
      line += "* ";
    }
    
  }
  return line;
}