-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49e9e78
commit 6cdfce5
Showing
6 changed files
with
142 additions
and
18 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/pages/exercises/array-operations/_codes/js/code/array-operations.jest.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { sum, product, sumOdds } from './array-operations.js'; | ||
|
||
describe('Array Operation', () => { | ||
test('adding values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(sum(values)).toBe(6); | ||
}); | ||
|
||
test.skip('adding values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(sum(values)).toBe(6); | ||
}); | ||
|
||
test.skip('adding values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(sum(values)).toBe(21); | ||
}); | ||
|
||
test.skip('adding odd values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(sumOdds(values)).toBe(4); | ||
}); | ||
|
||
test.skip('adding odd values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(sumOdds(values)).toBe(0); | ||
}); | ||
|
||
test.skip('adding odd values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(sumOdds(values)).toBe(9); | ||
}); | ||
|
||
test.skip('multiplying values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(product(values)).toBe(6); | ||
}); | ||
|
||
test.skip('multiplying values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(product(values)).toBe(8); | ||
}); | ||
|
||
test.skip('multiplying values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(product(values)).toBe(720); | ||
}); | ||
}); |
29 changes: 20 additions & 9 deletions
29
src/pages/exercises/array-operations/_codes/js/code/array-operations.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,59 @@ | ||
import { describe, test } from 'node:test'; | ||
import assert from 'node:assert'; | ||
import { sum, product, sumOdds } from './array-operations.js'; | ||
|
||
describe('Array Operation', () => { | ||
test('adding values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(sum(values)).toBe(6); | ||
|
||
assert.equal(sum(values), 6); | ||
}); | ||
|
||
test.skip('adding values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(sum(values)).toBe(6); | ||
|
||
assert.equal(sum(values), 6); | ||
}); | ||
|
||
test.skip('adding values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(sum(values)).toBe(21); | ||
|
||
assert.equal(sum(values), 21); | ||
}); | ||
|
||
test.skip('adding odd values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(sumOdds(values)).toBe(4); | ||
|
||
assert.equal(sumOdds(values), 4); | ||
}); | ||
|
||
test.skip('adding odd values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(sumOdds(values)).toBe(0); | ||
|
||
assert.equal(sumOdds(values), 0); | ||
}); | ||
|
||
test.skip('adding odd values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(sumOdds(values)).toBe(9); | ||
|
||
assert.equal(sumOdds(values), 9); | ||
}); | ||
|
||
test.skip('multiplying values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(product(values)).toBe(6); | ||
|
||
assert.equal(product(values), 6); | ||
}); | ||
|
||
test.skip('multiplying values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(product(values)).toBe(8); | ||
|
||
assert.equal(product(values), 8); | ||
}); | ||
|
||
test.skip('multiplying values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(product(values)).toBe(720); | ||
|
||
assert.equal(product(values), 720); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
src/pages/exercises/array-operations/_codes/js/code/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
48 changes: 48 additions & 0 deletions
48
src/pages/exercises/array-operations/_codes/js/response/array-operations.jest.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { sum, product, sumOdds } from './array-operations.js'; | ||
|
||
describe('Array Operation', () => { | ||
test('adding values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(sum(values)).toBe(6); | ||
}); | ||
|
||
test.skip('adding values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(sum(values)).toBe(6); | ||
}); | ||
|
||
test.skip('adding values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(sum(values)).toBe(21); | ||
}); | ||
|
||
test.skip('adding odd values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(sumOdds(values)).toBe(4); | ||
}); | ||
|
||
test.skip('adding odd values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(sumOdds(values)).toBe(0); | ||
}); | ||
|
||
test.skip('adding odd values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(sumOdds(values)).toBe(9); | ||
}); | ||
|
||
test.skip('multiplying values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(product(values)).toBe(6); | ||
}); | ||
|
||
test.skip('multiplying values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(product(values)).toBe(8); | ||
}); | ||
|
||
test.skip('multiplying values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(product(values)).toBe(720); | ||
}); | ||
}); |
29 changes: 20 additions & 9 deletions
29
src/pages/exercises/array-operations/_codes/js/response/array-operations.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,59 @@ | ||
import { describe, test } from 'node:test'; | ||
import assert from 'node:assert'; | ||
import { sum, product, sumOdds } from './array-operations.js'; | ||
|
||
describe('Array Operation', () => { | ||
test('adding values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(sum(values)).toBe(6); | ||
|
||
assert.equal(sum(values), 6); | ||
}); | ||
|
||
test('adding values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(sum(values)).toBe(6); | ||
|
||
assert.equal(sum(values), 6); | ||
}); | ||
|
||
test('adding values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(sum(values)).toBe(21); | ||
|
||
assert.equal(sum(values), 21); | ||
}); | ||
|
||
test('adding odd values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(sumOdds(values)).toBe(4); | ||
|
||
assert.equal(sumOdds(values), 4); | ||
}); | ||
|
||
test('adding odd values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(sumOdds(values)).toBe(0); | ||
|
||
assert.equal(sumOdds(values), 0); | ||
}); | ||
|
||
test('adding odd values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(sumOdds(values)).toBe(9); | ||
|
||
assert.equal(sumOdds(values), 9); | ||
}); | ||
|
||
test('multiplying values from [1, 2, 3]', () => { | ||
let values = [1, 2, 3]; | ||
expect(product(values)).toBe(6); | ||
|
||
assert.equal(product(values), 6); | ||
}); | ||
|
||
test('multiplying values from [2, 2, 2]', () => { | ||
let values = [2, 2, 2]; | ||
expect(product(values)).toBe(8); | ||
|
||
assert.equal(product(values), 8); | ||
}); | ||
|
||
test('multiplying values from [1, 2, 3, 4, 5, 6]', () => { | ||
let values = [1, 2, 3, 4, 5, 6]; | ||
expect(product(values)).toBe(720); | ||
|
||
assert.equal(product(values), 720); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
src/pages/exercises/array-operations/_codes/js/response/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |