File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 44// the keys of the object should be the first element of each inner array (country code)
55// the values of the object should be the second element of each inner array (currency code)
66
7- function Lookup ( coCuPairs ) {
7+ function Lookup ( countryCurrencyPairs ) {
88 // check if the argument is an array of arrays
99 if (
10- Array . isArray ( coCuPairs ) &&
10+ Array . isArray ( countryCurrencyPairs ) &&
1111 // check if each inner array is an array.
12- coCuPairs . every ( ( pair ) => Array . isArray ( pair ) ) &&
12+ countryCurrencyPairs . every ( ( pair ) => Array . isArray ( pair ) ) &&
1313 // check if each inner array has two elements.
14- coCuPairs . every ( ( pair ) => pair . length === 2 )
14+ countryCurrencyPairs . every ( ( pair ) => pair . length === 2 )
1515 // we can also use index to check the pair is an array as follows:
16- // for (let i = 0; i < coCuPairs .length; i++)
17- // return Array.isArray(coCuPairs [i])
16+ // for (let i = 0; i < countryCurrencyPairs .length; i++)
17+ // return Array.isArray(countryCurrencyPairs [i])
1818 ) {
19- return Object . fromEntries ( coCuPairs ) ;
19+ return Object . fromEntries ( countryCurrencyPairs ) ;
2020 }
2121 return "Invalid input: expected an array of arrays" ;
2222}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ Example
3636Given: [['US', 'USD'], ['CA', 'CAD']]
3737
3838When
39- Lookup(coCuPairs ) is called
39+ Lookup(countryCurrencyPairs ) is called
4040
4141Then
4242It should return:
You can’t perform that action at this time.
0 commit comments