Skip to content
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
48 changes: 48 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copilot Instructions for Module-Data-Flows

Use these repo-specific guidelines so AI coding agents are productive and non-disruptive across this multi-exercise teaching repo.

## Scope & Structure

- This repo hosts many standalone exercises grouped by topic: [Sprint-1](Sprint-1), [Sprint-3](Sprint-3), [challenges](challenges), [debugging](debugging), [fetch](fetch).
- Work locally within the specific exercise folder. Avoid cross-folder refactors or adding global dependencies.
- Read each exercise’s README first (e.g. [Sprint-1/destructuring/exercise-3/readme.md](Sprint-1/destructuring/exercise-3/readme.md), [Sprint-3/dead-code/README.md](Sprint-3/dead-code/README.md)).

## Workflows

- Formatting: run `npm run format` at repo root (see [package.json](package.json)). Keep edits Prettier-friendly.
- Tests (root): `npm test` runs Jest across the repo using a broad match (see [package.json](package.json)). Prefer running tests in the relevant subfolder when possible to keep scope tight.
- Tests (subfolders): some folders have their own config/scripts:
- Unit testing hub: [challenges/unit-testing/package.json](challenges/unit-testing/package.json) → run `npm test` in that folder.
- ESM example: [debugging/exampleEJS/package.json](debugging/exampleEJS/package.json) runs Jest via Node’s `--experimental-vm-modules`.
- Script-free exercises: execute files directly with Node to check console output (e.g., `node Sprint-3/dead-code/exercise-1.js`).

## Module Systems

- Default is CommonJS: use `require(...)` and `module.exports` (e.g., [challenges/unit-testing/passing-tests/factorial/factorial.test.js](challenges/unit-testing/passing-tests/factorial/factorial.test.js)).
- Some folders opt into ESM with `"type": "module"` (e.g., [debugging/exampleEJS/package.json](debugging/exampleEJS/package.json)). Match the module format of the folder you’re editing.

## Testing Patterns

- Tests are colocated with exercises. Implementations sit beside tests with matching basenames (e.g., `factorial.test.js` ↔ `factorial.js`).
- See [challenges/unit-testing/passing-tests/factorial/factorial.test.js](challenges/unit-testing/passing-tests/factorial/factorial.test.js) and [challenges/unit-testing/passing-tests/factorial/factorial.js](challenges/unit-testing/passing-tests/factorial/factorial.js).
- Some kata folders intentionally provide empty test files to be completed via TDD (e.g., [challenges/unit-testing/katas-tdd/roman-numerals/convert-to-old-roman.test.js](challenges/unit-testing/katas-tdd/roman-numerals/convert-to-old-roman.test.js)).
- Jest version is pinned in package files; avoid adding transform layers. Keep implementations simple and idiomatic JS.
- To focus tests from root: `npm test -- <relative/test/path> -t "pattern"`.

## Exercise-Specific Conventions

- Dead code refactors: maintain exact final console output while removing unused/duplicated logic (see [Sprint-3/dead-code](Sprint-3/dead-code)). Prefer pure functions and minimal variables.
- Destructuring tasks: follow the README’s output formatting precisely; use object/array destructuring where asked (see [Sprint-1/destructuring](Sprint-1/destructuring)).
- Writing tests: when a test is a stub, derive behaviour from the README then write tests first, followed by the simplest implementation.

## Do / Don’t

- Do: keep changes local to a single exercise; preserve file names and locations; match the folder’s module system; run only relevant tests.
- Don’t: introduce new npm deps, change top-level configs, or modify unrelated exercises to “fix” failing global runs.

## Start Here (per task)

- Open the exercise README and files in its folder.
- If tests exist, run them in the subfolder and implement the missing logic. If tests are stubs, write them first based on the README.
- Verify with local run (`node ...` or `npm test`), then format (`npm run format`).
4 changes: 2 additions & 2 deletions Sprint-3/dead-code/exercise-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ let testName = "Jerry";
const greeting = "hello";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This initial Jerry name is also never used is it?


function sayHello(greeting, name) {
const greetingStr = greeting + ", " + name + "!";
// const greetingStr = greeting + ", " + name + "!";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done for doing this correctly! But the instructions said to remove the code and you commented it out! This is important, because comments taks up space in your codebase, so commenting out and deleting are not the same thing! Make sure to delete them next time :)

return `${greeting}, ${name}!`;
console.log(greetingStr);
//console.log(greetingStr);
}

testName = "Aman";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that comment at the bottom on line 16 is also redundant!

Expand Down
8 changes: 4 additions & 4 deletions Sprint-3/dead-code/exercise-2.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Remove the unused code that does not contribute to the final console log

const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
const capitalisedPets = pets.map((pet) => pet.toUpperCase());
//const capitalisedPets = pets.map((pet) => pet.toUpperCase());
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");

function logPets(petsArr) {
petsArr.forEach((pet) => console.log(pet));
}
// function logPets(petsArr) {
// petsArr.forEach((pet) => console.log(pet));
// }

function countAndCapitalisePets(petsArr) {
const petCount = {};
Expand Down
Loading
Loading