Skip to content

Commit 9e7a052

Browse files
committed
Implemented lookup.js function
1 parent 21e1adc commit 9e7a052

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sprint-2/implement/lookup.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
function createLookup() {
1+
function createLookup(pairs) {
22
// implementation here
3+
// Creates empty object that will store our,
4+
// country → currency
5+
const lookup = {};
6+
// Loop through each pair in the input array
7+
for (const [country, currency] of pairs) {
8+
// Use the country code as they key
9+
// Assigns the correspoding currency code as the value
10+
lookup[country] = currency;
11+
}
12+
// returns the completed lookup object
13+
return lookup;
314
}
415

516
module.exports = createLookup;

0 commit comments

Comments
 (0)