for (var i = 5; i >= 1; i--) { var str = ""; for (var j = i; j >= 1; j--) str += j; console.log(str); }