You can write it like this:
for(let i = 0;i<=5;i++){
let str = "";
for(let j = i;j<5;j++){
str += " ";
}
for(let j = 0;j<i;j++){
str += "*";
}
console.log(str)
}
This method can be used in all other programming languages, cause there's no special js syntax or special js built-in function.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…