Day 57: Pattern using loops of 100DaysCodingChallenge
Hello all,
#day57
Day57
Today's my task was to Print the below Pattern using loops.
Hollow Full Pyramid Numbers Pattern
1
1 2
1 3
1 4
1 5
1 2 3 4 5 6
I have started the 100 days of coding challenge to improve my programming skills..
Code :
let a = prompt("Enter a number : "); let string = ""; function full(a) { for (let i = 1; i <= a; i++) { for (let j = 1; j <= a - i; j++) { string += " "; } for (let k = 1; k <= i; k++) { if (i == 1 || k == 1 || i == a || k == i) { string += " "+k+" "; } else { string += " "; } } string += "\n"; } console.log(string); } full(a);
Output :
Happy Coding:)
Thank you...
Comments
Post a Comment