https://github.com/prazdevs/cdp-recruitment-javascript
https://github.com/prazdevs/cdp-recruitment-javascript
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/prazdevs/cdp-recruitment-javascript
- Owner: prazdevs
- Created: 2025-05-26T13:52:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-26T13:53:04.000Z (about 1 year ago)
- Last Synced: 2025-06-26T08:10:06.351Z (12 months ago)
- Language: JavaScript
- Size: 49.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Javascript developer test
## Features
- Filtering people and countries based on their animal names.
- Programmatic use.
- CLI.
## Usage
Until published CLI must be either built and run or used through a Node-like tool running TypeScript (TSX).
### Build and run
```sh
pnpm install
pnpm run build
npx country-filter --filter=ry
```
### Run as TypeScript
```sh
pnpx tsx src/cli.ts --filter=ry
```
## Options
- `filter`: string to use as filter for animal names.
- `count`: add animal count to people's name and people count to country's name.
## Developer notes
Testing is done through [`vitest`](https://vitest.dev) within the `test/` directory:
- `.fixture.ts` files contain fixtures based on random-generated data (using `fakerjs`).
- `.spec.ts` files contain unit tests.
- `.bench.ts` files contain performance tests.
---
Background
Filter
Your job is to write a command-line interface in Node.js.
This program has to filter a list of elements containing a pattern.
Details:
- In the following file `data.js`, there are `Countries` containing `Peoples` containing `Animals`.
- Only animals containing the pattern passed as argument (e.g. `ry`) are displayed. The order should be kept intact.
- Empty array after filtering are NOT returned.
Sample of running the command, and its output:
```shell script
$ node app.js --filter=ry
[
{
name: 'Uzuzozne',
people: [
{
name: 'Lillie Abbott',
animals: [
{
name: 'John Dory'
}
]
}
]
},
{
name: 'Satanwi',
people: [
{
name: 'Anthony Bruno',
animals: [
{
name: 'Oryx'
}
]
}
]
}
]
```
Count
The next goal is to print the counts of People and Animals by counting the number of children and appending it in the name, eg. `Satanwi [2]`.
Sample of running the command, and its output:
```shell script
node app.js --count
[ { name: 'Dillauti [5]',
people:
[ { name: 'Winifred Graham [6]',
animals:
[ { name: 'Anoa' },
{ name: 'Duck' },
{ name: 'Narwhal' },
{ name: 'Badger' },
{ name: 'Cobra' },
{ name: 'Crow' } ] },
{ name: 'Blanche Viciani [8]',
animals:
[ { name: 'Barbet' },
{ name: 'Rhea' },
{ name: 'Snakes' },
{ name: 'Antelope' },
{ name: 'Echidna' },
{ name: 'Crow' },
{ name: 'Guinea Fowl' },
{ name: 'Deer Mouse' } ] },
...
...
]
```
Requirements
- The code must be available in a GIT repository
- No library/modules should be used, except for the testing library
Appreciation
We will be really attentive to:
- Code readability, structure and consistency
- Tests, and how they are written