Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pyramidNums(input) {
- let num = Number(input[0]);
- let currentNum = 1;
- let isBigger = false;
- let printLine = "";
- for (let rows = 1; rows <= num; rows++) {
- for (let columns = 1; columns <= rows; columns++) {
- if (currentNum > num) {
- isBigger = true;
- break;
- }
- printLine += currentNum + " ";
- currentNum++;
- }
- console.log(printLine);
- printLine = "";
- if (isBigger) {
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment