Skip to content

Commit 79517e9

Browse files
committed
add lookup.js
1 parent b32fa68 commit 79517e9

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎Sprint-2/implement/lookup.js‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
function createLookup() {
1+
function createLookup(countryCurrencyPairs) {
22
// implementation here
3+
const lookup = {};
4+
5+
for (const pair of countryCurrencyPairs) {
6+
const [countryCode, currencyCode] = pair;
7+
lookup[countryCode] = currencyCode;
8+
}
9+
10+
return lookup;
311
}
412

513
module.exports = createLookup;
14+
15+
module.exports = createLookup;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,14 @@ It should return:
3333
'CA': 'CAD'
3434
}
3535
*/
36+
test("creates a country currency code lookup for multiple codes", () => {
37+
const countryCurrencyPairs = [
38+
["US", "USD"],
39+
["CA", "CAD"],
40+
];
41+
42+
expect(createLookup(countryCurrencyPairs)).toEqual({
43+
US: "USD",
44+
CA: "CAD",
45+
});
46+
});

0 commit comments

Comments
 (0)