Skip to content
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

chore: convert pyramid generator project to lab #567

Open
jdwilkin4 opened this issue Sep 9, 2024 · 0 comments · May be fixed by #590
Open

chore: convert pyramid generator project to lab #567

jdwilkin4 opened this issue Sep 9, 2024 · 0 comments · May be fixed by #590
Assignees
Labels
Frontend Cert Labs Team This work is for the labs team only

Comments

@jdwilkin4
Copy link
Contributor

jdwilkin4 commented Sep 9, 2024

We currently have this pyramid generator project in the beta JS curriculum.
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/step-118

the reason why it has so many steps because it is currently being used to teach all of the JS fundamentals like functions, strings, arrays, variables , etc.

But with the new frontend cert, we already have plenty of smaller workshops and labs to teach JS fundamentals.
So we are going to convert this project into a lab.

here is the current solution:

const character = "#";
const count = 8;
const rows = [];
let inverted = true;

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);

You don't need to keep the global variables.
You are free to just create a function that will generate the pyramid with a character, count and isInverted boolean.
Or you can have two functions if you want. One for the padRow and one to generate the pyramid. It is up to you.

Play around with the current solution and see how you can refactor this to convert it to a lab.
Then add your user stories.

@jdwilkin4 jdwilkin4 added Frontend Cert Labs Team This work is for the labs team only labels Sep 9, 2024
@Dario-DC Dario-DC self-assigned this Sep 12, 2024
@Dario-DC Dario-DC linked a pull request Sep 16, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Cert Labs Team This work is for the labs team only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants