Posts

Showing posts from July, 2023

Day 65: Pattern using loops of 100DaysCodingChallenge

Image
Hello all,  #day65  Day65  Today's my task was to Print the below Pattern using loops. Inverted Triangle of 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 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 = a; i >= 1; 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 Codi

Day 64: Pattern using loops of 100DaysCodingChallenge

Image
Hello all,  #day64  Day64  Today's my task was to Print the below Pattern using loops. Full Triangle by Alphabets A B C D E F G H I J K L M N O P Q R S T U V W X Y I have started the 100 days of coding  challenge  to improve my programming skills.. Code :  let n = prompt("Enter a number : "); //let n = 5; let string = ""; let count = 0; // 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(count + 65) +" "; count++; } string += "\n"; } console.log(string); Output :         Happy Coding:) Day 64 Of 100 Days Coding Challenge Thank you...     

Day 63: Pattern using loops of 100DaysCodingChallenge

Image
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:) Day 63 Of 100 Days Coding Challenge Thank you...     

Day 62: Pattern using loops of 100DaysCodingChallenge

Image
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 :   

Day 61: Pattern using loops of 100DaysCodingChallenge

Image
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:) Day 61 Of 100 Days Coding Challenge Thank you...     

Day 60: Pattern using loops of 100DaysCodingChallenge

Image
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:) Day 60 Of 100 Days Coding Challenge Thank you...     

Day 59: Pattern using loops of 100DaysCodingChallenge

Image
Hello all,  #day59  Day59  Today's my task was to Print the below Pattern using loops. Half Pyramid Pattern using Alphabets A A B A B C A B C D A B C D 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 half(a) { for (let i = 1; i <= a; 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:) Day 59 Of 100 Days Coding Challenge Thank you...     

Day 58: Pattern using loops of 100DaysCodingChallenge

Image
Hello all,  #day58  Day58  Today's my task was to Print the below Pattern using loops. Pascal Triangle Numbers Pattern 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 I have started the 100 days of coding  challenge  to improve my programming skills.. Code :  let a = prompt("Enter a number : "); let numRows = a; var generate = function(numRows) { let triangle = [[1], [1,1]] if(numRows === 0){ return [] } else if(numRows == 1){ return [[1]] } else if(numRows == 2){ return [[1], [1,1]] } else { for(let i = 2; i < numRows; i++){ addRow(triangle) } } return triangle }; var addRow = function(triangle){ let previous = triangle[triangle.length - 1] let newRow = [1] for(let i = 0; i < previous.length - 1; i++){ let current = previous[i] let next = previous[i+1] newRow.push(current + next) } newRow.push(1) return trian

Day 57: Pattern using loops of 100DaysCodingChallenge

Image
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:) Day 57 Of 100 Days Coding Challenge Thank you...     

Day 56: Pattern using loops of 100DaysCodingChallenge

Image
Hello all,  #day56  Day56  Today's my task was to Print the below Pattern using loops. Hollow Half Pyramid Numbers Pattern 1 1 2 1 3 1 4 1 5 I have started the 100 days of coding  challenge  to improve my programming skills.. Code :  let n = prompt("Enter a number : "); let string = ""; function hollow(n) { //let n = 5; let string = ""; // External loop for (let i = 1; i <= n; i++) { // printing spaces for (let j = 1; j <= n - i; j++) { string += " "; } // printing star for (let k = 1; k <= 2 * i - 1; k++) { if(k === 1 || k === i || i === n) { string += k+" "; } else { string += " "; } } string += "\n"; } console.log(string); } hollow(n); Output :         Happy Coding:) Day 56 Of 100 Days Coding Challenge Thank you...     

Day 55: Pattern using loops of 100DaysCodingChallenge

Image
Hello all,  #day55  Day55  Today's my task was to Print the below Pattern using loops. Full Pyramid by Number 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 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) { let k = 0; for (let i = 0; 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 += a+" "; } string += "\n"; } console.log(string); } full(a); Output :         Happy Coding:) Day 55 Of 100 Days Coding Challenge Thank you...     

Day 54: Pattern using loops of 100DaysCodingChallenge

Image
Hello all,  #day54  Day54  Today's my task was to Print the below Pattern using loops. Full Inverted Numbers Pyramid 6 5 5 5 4 4 4 4 4 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 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 = 0; for (let i = 0; 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 += a - i+" "; } string += "\n"; } console.log(string); } full(a); Output :         Happy Coding:) Day 54 Of 100 Days Coding Challenge Thank you...