Advertisement
Spocoman

07. Triangle Of Numbers

Jan 13th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function triangleOfNumbers (number) {
  2.  
  3.     for (let i = 1; i <= number; i++) {
  4.         let printLine = '';
  5.         for (let j = 0; j < i; j++){
  6.             printLine += i + ' ';
  7.         }
  8.         console.log(printLine);
  9.     }
  10.  
  11. }
  12.  
  13.  
  14.  
  15. Решение с repeat():
  16.  
  17. function triangleOfNumbers (number) {
  18.  
  19.     for (let i = 1; i <= number; i++) {
  20.         console.log((i.toString() + ' ').repeat(i).trimEnd());
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement