From a24ae697425b7a297be49fbe118bd8a6b1063707 Mon Sep 17 00:00:00 2001 From: AndriiKot Date: Fri, 28 Feb 2025 00:01:48 +0100 Subject: [PATCH 1/2] 'Pyramid Generator' docs: README.md update (variation_2) --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7a9b850..e2d2d9c 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,19 @@ # Pyramid Generator -JavaScript is a powerful scripting language -that you can use to make web pages interactive. -It's one of the core technologies of the web, + +JavaScript is a powerful scripting language +that you can use to make web pages interactive. +It's one of the core technologies of the web, along with HTML and CSS. All modern browsers support JavaScript. -In this practice project, you'll learn fundamental -programming concepts in JavaScript by coding your -own Pyramid Generator. You'll learn how to work -with arrays, strings, functions, loops, +In this practice project, you'll learn fundamental +programming concepts in JavaScript by coding your +own Pyramid Generator. You'll learn how to work +with arrays, strings, functions, loops, if/else statements, and more. +### Result + +```md ! !!! !!!!! @@ -20,6 +24,38 @@ if/else statements, and more. !!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!! +``` + +### Code + +```js +const character = "!"; +const count = 10; +const rows = []; +let inverted = false; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +for (let i = 1; i <= count; i++) { + if (inverted) { + rows.unshift(padRow(i, count)); + } else { + rows.push(padRow(i, count)); + } +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` + +[Back to top](#pyramid-generator) From cc83f97a037cd6267b5cf1070d86c15d3ce57325 Mon Sep 17 00:00:00 2001 From: AndriiKot Date: Fri, 28 Feb 2025 18:18:39 +0100 Subject: [PATCH 2/2] 'Pyramid Generator' docs: add end-product folder and README.md update and .gitignore update --- .gitignore | 3 ++- README.md | 20 ++++++++++++++++++++ end-product/piramidGenerator.js | 24 ++++++++++++++++++++++++ icons/javascript-1.svg | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 end-product/piramidGenerator.js create mode 100644 icons/javascript-1.svg diff --git a/.gitignore b/.gitignore index ea7af55..e43b445 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -*.log +!**/*.svg +*.log .DS_Store diff --git a/README.md b/README.md index e2d2d9c..448cce4 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,26 @@ own Pyramid Generator. You'll learn how to work with arrays, strings, functions, loops, if/else statements, and more. +### technologies + + + + + + + + + + + + +
JavaScript
+ + JavaScript + +
+ + ### Result ```md diff --git a/end-product/piramidGenerator.js b/end-product/piramidGenerator.js new file mode 100644 index 0000000..5c8f65b --- /dev/null +++ b/end-product/piramidGenerator.js @@ -0,0 +1,24 @@ +const character = "!"; +const count = 10; +const rows = []; +let inverted = false; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +for (let i = 1; i <= count; i++) { + if (inverted) { + rows.unshift(padRow(i, count)); + } else { + rows.push(padRow(i, count)); + } +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); \ No newline at end of file diff --git a/icons/javascript-1.svg b/icons/javascript-1.svg new file mode 100644 index 0000000..b56c0b7 --- /dev/null +++ b/icons/javascript-1.svg @@ -0,0 +1 @@ + \ No newline at end of file