Day 60: Pattern using loops of 100DaysCodingChallenge
Hello all,
#day60
Day60
Today's my task was to Print the below Pattern using loops.
Inverted Half Pyramid of Alphabets
A B C D E
A B C D
A B C
A B
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 half(a) { for (let i = a; i >= 0; i--) { for (let j = 1; j <= i; j++) { //string += "* "; string += String.fromCharCode("A".charCodeAt(0) - 1 + j) +" "; } string += "\n"; } console.log(string); } half(a);
Output :
Happy Coding:)
Thank you...
Comments
Post a Comment