Skip to content

Commit

Permalink
Merge branch 'exercism:main' into lens-person
Browse files Browse the repository at this point in the history
  • Loading branch information
Cool-Katt authored Jun 18, 2024
2 parents a57070e + 76988d6 commit fbf341c
Show file tree
Hide file tree
Showing 180 changed files with 895 additions and 807 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- name: Use Node.js LTS (18.x)
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
Expand All @@ -32,7 +32,7 @@ jobs:
node-version: ['18', '20']

steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout PR
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29

- name: Use Node.js LTS (18.x)
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
Expand All @@ -37,7 +37,7 @@ jobs:

steps:
- name: Checkout PR
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-code-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: 'Checkout code'
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- name: Use Node.js LTS (18.x)
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
Expand Down
4 changes: 2 additions & 2 deletions concepts/regular-expressions/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This concept is focused on using regular expressions in JavaScript. If you want
## How to create Regular Expressions

In JavaScript, a regular expressions is mostly written in the format `/pattern/modifiers` where 'pattern' is the main regex, and 'modifiers' are a series of characters which we can add to indicate special options (like superpowers).
In JavaScript, regular expressions are mostly written in the format `/pattern/modifiers` where 'pattern' is the main regex, and 'modifiers' are a series of characters which we can add to indicate special options (like superpowers).

Nevertheless, we have two ways of creating a regular expression:

Expand Down Expand Up @@ -119,7 +119,7 @@ funnyQuote.match(regex3);

### Replace

The [replace()][mdn-regex-replace] method in JavaScript allows us to search for a value within a given string, and replacing it with a desired new value.
The [replace()][mdn-regex-replace] method in JavaScript allows us to search for a value within a given string, and replace it with a new value.

```javascript
string.replace(searchValue, newValue);
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/amusement-park/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/amusement-park"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/annalyns-infiltration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"directory": "exercises/concept/annalyns-infiltration"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/bird-watcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/bird-watcher"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/coordinate-transformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/coordinate-transformation"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/custom-signs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/custom-signs"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/elyses-analytic-enchantments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/elyses-analytic-enchantments"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/elyses-destructured-enchantments"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/elyses-enchantments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"directory": "exercises/concept/elyses-enchantments"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/elyses-looping-enchantments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/elyses-looping-enchantments"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"directory": "exercises/concept/elyses-transformative-enchantments"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/factory-sensors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"directory": "exercises/concept/factory-sensors"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/freelancer-rates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/freelancer-rates"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
20 changes: 11 additions & 9 deletions exercises/concept/fruit-picker/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@

You are creating a new online portal for your patrons to order their fruit fresh from the grocer. The grocer has an API that you can use to see if they have the inventory desired by your customers. You need to create a small library of functions for interacting with the grocer's API.

## 1. Create a callback to be called when the order is successful
## 1. Notify your customer when their order was successful

Write a callback function called `onSuccess` to be called when the order is successful. It should invoke the imported `notify` function passing a success message to it.
The portal should notify your customer if their order was successful. Define the `onSuccess` callback function that will be called if the order was successful due to the grocer having enough fruit in stock. This function should invoke the imported `notify` function, passing `{ message: 'SUCCESS' }` to let your customer know that their order was successful.

```javascript
onSuccess();
// => `notify` called with `{ message: 'SUCCESS' }`
```

## 2. Create a callback to be called when the order fails with an error
## 2. Notify your customer when their order was unsuccessful

Write a callback function called `onError` to be called when the order encounters an error. It should invoke the imported `notify` function passing an error message to it.
The portal should notify your customer if their order was unsuccessful. Define the `onError` callback function that will be called if the order was unsuccessful because the grocer _does not have_ the fruit in stock or there was an error. This function should invoke the imported `notify` function, passing `{ message: 'ERROR' }` to let your customer know that their order was unsuccessful.

```javascript
onError();
// => `notify` called with `{ message: 'ERROR' }`
```

## 3. Create a wrapper to wrap the external api function
## 3. Create an API wrapper to wrap the grocer's API order function

The grocer's API provides a function to order from their inventory called `order`. It receives three arguments: a _query_, a _callback_ function to be invoked when the order is successful, and a _callback_ function to be invoked when the order encounters an error. You decide to wrap the api function call in a newly defined function `orderFromGrocer` to insulate your codebase from external changes. Your function should forward the arguments (which match the provided api function) to the api function.
Fruit orders are placed through the grocer's API via the provided `order` function. This function receives three arguments: a _query_, containing the `variety` and `quantity` of fruit requested, a _callback_ function to be invoked when the order is successful, and a _callback_ function to be invoked when the order encounters an error.

You want to insulate your codebase from potential external changes and decide to wrap the call to the `order` function inside a new function named `orderFromGrocer`. Implement the `orderFromGrocer` function that attempts to place an order via a call to the grocer's API `order` function, making sure to forward the arguments passed into `orderFromGrocer` to the API call.

The query takes the form of an _object_:

Expand All @@ -42,11 +44,11 @@ orderFromGrocer(
// => `order` was called with the query and the callbacks
```

## 4. Create a convenient short function
## 4. Simplify handling placed orders

You find that you are calling this function from many different places with the same functions. Seeing an opportunity to refactor your code, you want to create a function where you can supply the variety and quantity to order as arguments.
Your customers are now able to place fruit orders via your portal, however, you notice that you are invoking the `orderFromGrocer` function in many different places across your codebase, each time having to pass in a `query` and the two `callback` functions as arguments. Seeing an opportunity to refactor your code, you think it would be simpler if you could place an order by just passing the `variety` and `quantity` of fruit required. Define the `postOrder` helper function that takes `variety` and `quantity` as arguments and attempts to place an order with the grocer.

```javascript
postOrder('peach', 100);
// => order submitted for 100 peaches
// => order placed for 100 peaches
```
2 changes: 1 addition & 1 deletion exercises/concept/fruit-picker/fruit-picker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('task 2', () => {
});

describe('task 3', () => {
test('order from grocer passes callback function arguments forward', () => {
test('orderFromGrocer passes query and callback function arguments forward', () => {
const query = { variety: 'apple', quantity: 10 };
orderFromGrocer(query, onSuccess, onError);
expect(order).toHaveBeenCalledTimes(1);
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/fruit-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/fruit-picker"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/high-score-board/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/high-score-board"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/lasagna-master/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"directory": "exercises/concept/lasagna-master"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@exercism/eslint-config-javascript": "^0.6.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"babel-jest": "^29.6.4",
"core-js": "~3.37.0",
"core-js": "~3.37.1",
"eslint": "^8.49.0",
"jest": "^29.7.0"
},
Expand Down
Loading

0 comments on commit fbf341c

Please sign in to comment.