Skip to content

Commit 2601bda

Browse files
committed
Update add module functionality to allow multiple numbers as args.
Add a lint job in CI workflow.
1 parent 400c84d commit 2601bda

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@ on:
1717
workflow_dispatch:
1818

1919
jobs:
20+
lint:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Clone repo
25+
uses: actions/checkout@v4
26+
27+
- name: Install NodeJS
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 22.12.0
31+
32+
- name: Cache npm dependencies
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.npm
36+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
37+
38+
- name: Install dependencies
39+
run: npm ci
40+
41+
- name: Run linter
42+
run: npm run lint
43+
2044
test:
2145
runs-on: ubuntu-latest
2246

src/add.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @param {number} a
3-
* @param {number} b
4-
* @returns {number}
2+
* Add any number of arguments
3+
* @param {...number} args - The numbers to be added
4+
* @returns {number} - sum of the numbers
55
*/
6-
export function add(a, b) {
7-
return a + b;
6+
export function add(...args) {
7+
return args.reduce((prev, curr) => prev + curr, 0);
88
}

0 commit comments

Comments
 (0)