Skip to content

'Pyramid Generator' docs: README.md update (variation_2) #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.log
!**/*.svg
*.log
.DS_Store


Expand Down
70 changes: 63 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
# 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.

### technologies

<table>
<thead>
<tr>
<th height=33 width=91>JavaScript</th>
</tr>
</thead>
<tbody>
<tr>
<td height=33 width=91>
<a href=https://ecma-international.org/publications-and-standards/standards/>
<img src=https://github.com/AndriiKot/JS__Pyramid_Generator__FreeCodeCamp/blob/main/icons/javascript-1.svg alt=JavaScript>
</a>
</td>
</tr>
</tbody>
</table>


### Result

```md
!
!!!
!!!!!
Expand All @@ -20,6 +44,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)



24 changes: 24 additions & 0 deletions end-product/piramidGenerator.js
Original file line number Diff line number Diff line change
@@ -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);
1 change: 1 addition & 0 deletions icons/javascript-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.