Day 62: Pattern using loops of 100DaysCodingChallenge
Hello all,
#day62
Day62
Today's my task was to Print the below Pattern using loops.
Full Pyramid by Alphabet
A
A A A
A A A A A
A A A A A A A
A A A A A A A A
A A A A A A A A A A
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 b = 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 k = 2 * (i - b); k >= 0; k--) {
//console.log('j2', j);
      //string += a+" ";
     // string += String.fromCharCode("A".charCodeAt(0) + 1 - k)+" ";
      string += String.fromCharCode("A".charCodeAt(0) - 1 + b) +" ";
    }
    string += "\n";
  }
  console.log(string);
}
full(a);Output :
Happy Coding:)
Thank you...

 
 
 
Comments
Post a Comment