Day 63: Pattern using loops of 100DaysCodingChallenge

Hello all, 

#day63 

Day63 

Today's my task was to Print the below Pattern using loops.


Full Pyramid by Alphabets

A
A B C
A B C D E
A B C D E F G
A B C D E F G H I

I have started the 100 days of coding challenge to improve my programming skills..

Code : 

//let n = 5;
let n = prompt("Enter a number : ");
let string = "";
// External loop
for (let i = 1; i <= n; i++) {
  // creating spaces
  for (let j = 0; j < n - i; j++) {
    string += "  ";
  }
  // creating alphabets
  for (let k = 0; k < 2 * i - 1; k++) {
    string += String.fromCharCode(k + 65) +" ";
  }
  string += "\n";
}
console.log(string);

Output :     

 



Happy Coding:)

Thank you...     

Comments

Popular posts from this blog

Day 55: Pattern using loops of 100DaysCodingChallenge

Day 7: Square or Power Integer Numbers of 100DaysCodingChallenge

Day 45: Pattern using loops of 100DaysCodingChallenge