I wrote this method that draw a Triangle. For example if you call drawTriangle(5) you get the following output:

this is my code :-
function drawTriangle(t){
for (let i=1; i <= t; i++)
{
for (let j=1; j<=i; j++)
{
console.log(j+" ");
}
console.log("\n");
}
}
let t = 5 ;
drawTriangle(t);
I can not make them in a line I don't Know where is the problem .

\n) would be more performant. Additionally,console.log()is meant as a debugging tool and shoule be used as such if possible, opting for the function to return the triangle as a string that you then log to the console.