Day 61: Pattern using loops of 100DaysCodingChallenge
Hello all,
#day61
Day61
Today's my task was to Print the below Pattern using loops.
Full Pyramid Triangle of Alphabets
A
B B B
C C C C C
D D D D D D D
E E E E E E E E E
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) {
let k = 1;
for (let i = 1; i <= a; i++) {
//console.log('j1', a - i);
for (let j = 2 * (a-i); j >= 0 ; j--) {
//console.log('j1', j);
string += " ";
}
//console.log('j2', i - k);
for (let j = 2 * (i - k); j >= 0; j--) {
//console.log('j2', j);
//string += i+" ";
string += String.fromCharCode("A".charCodeAt(0) - 1 + i) +" ";
}
string += "\n";
}
console.log(string);
}
full(a);Output :
Happy Coding:)
Thank you...

Comments
Post a Comment