Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function triangleOfNumbers (number) {
- for (let i = 1; i <= number; i++) {
- let printLine = '';
- for (let j = 0; j < i; j++){
- printLine += i + ' ';
- }
- console.log(printLine);
- }
- }
- Решение с repeat():
- function triangleOfNumbers (number) {
- for (let i = 1; i <= number; i++) {
- console.log((i.toString() + ' ').repeat(i).trimEnd());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement