Skip to content

Commit e2f4029

Browse files
committed
clearing tasks under implement section on sprint 2
1 parent 7385171 commit e2f4029

6 files changed

Lines changed: 19 additions & 27 deletions

File tree

‎Sprint-2/implement/contains.js‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function contains(keyInput,valueInput) {
2-
if (Array.isArray(keyInput) == true) {
1+
function contains(keyInput, valueInput) {
2+
if (Array.isArray(keyInput) == true) {
33
return false;
44
} else {
55
for (const key in keyInput) {
@@ -11,6 +11,4 @@ function contains(keyInput,valueInput) {
1111
return false;
1212
}
1313

14-
}
15-
1614
module.exports = contains;

‎Sprint-2/implement/lookup.js‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,5 @@ function createLookup(countryCurrencyPairs) {
66
}
77
return pairs;
88
}
9-
console.log(
10-
createLookup([
11-
["UK", "GBP"],
12-
["ET", "ETB"],
13-
["CA", "CAD"],
14-
["FR", "EUR"],
15-
])
16-
);
179

1810
module.exports = createLookup;

‎Sprint-2/implement/lookup.test.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
const createLookup = require("./lookup.js");
22

33
test("creates a country currency code lookup for multiple codes", () => {
4+
expect([["UK", "GBP"]]).toEqual({ UK: "GBP" });
5+
});
6+
test("creates an empty country currency code returns empty lookup ", () => {
7+
expect([]).toEqual({});
8+
});
9+
10+
test("for multiple country currency returns multiple lookup", () => {
411
expect([
5-
["US", "USD"],
6-
["CA", "CAD"],
712
["UK", "GBP"],
8-
]).toEqual({ US: "USD", CA: "CAD", UK: "GBP" });
13+
["ET", "ETB"],
14+
["FR", "EUR"],
15+
]).toEqual({ UK: "GBP", ET: "ETB", FR: "EUR" });
916
});

‎Sprint-2/implement/querystring.js‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,4 @@ function parseQueryString(queryString) {
4141
return queryParams;
4242
}
4343

44-
console.log(parseQueryString("equation=a=b-2")); // "equation: a=b-2"
45-
console.log(parseQueryString("key1=value&&key2=value2&")); // key1:"value1" key2:"value2"
46-
console.log(parseQueryString("=value")); // "":value
47-
console.log(parseQueryString("key=")); // key:""
48-
console.log(parseQueryString("=")); // {"":""}
49-
console.log(parseQueryString("%24half=1%2F2")); //{$half: "1/2",}
50-
console.log(parseQueryString("full+name=John+Doe")); //{"full name": "John Doe",}
51-
console.log(parseQueryString());
52-
5344
module.exports = parseQueryString;

‎Sprint-2/implement/tally.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
function tally(items) {
22
const result = {};
3+
if (!Array.isArray(items)) {
4+
throw new Error("Invalid input!");
5+
}
36
for (const item of items) {
47
result[item] = (result[item] || 0) + 1;
58
}
69
return result;
710
}
8-
console.log(tally(["a", "b", "a", "c"]));
9-
console.log(tally([])); // {}
10-
console.log(tally("never mind"));
11+
1112
module.exports = tally;

‎Sprint-2/implement/tally.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ test("given an array of duplicated items returns an object containing the counte
3838
// Given an invalid input like a string
3939
// When passed to tally
4040
// Then it should throw an error
41+
test("tally on an empty array returns an empty object", () => {
42+
expect(() => tally("string").toThrow("Invalid input!"));
43+
});

0 commit comments

Comments
 (0)