File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 77function Lookup ( countryCurrencyPairs ) {
88 // check if the argument is an array of arrays
99 if (
10- Array . isArray ( countryCurrencyPairs ) &&
10+ ! Array . isArray ( countryCurrencyPairs ) ||
1111 // check if each inner array is an array.
12- countryCurrencyPairs . every ( ( pair ) => Array . isArray ( pair ) ) &&
12+ ! countryCurrencyPairs . every ( ( pair ) => Array . isArray ( pair ) ) ||
1313 // check if each inner array has two elements.
14- countryCurrencyPairs . 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:
1616 // for (let i = 0; i < countryCurrencyPairs.length; i++)
1717 // return Array.isArray(countryCurrencyPairs[i])
1818 ) {
19- return Object . fromEntries ( countryCurrencyPairs ) ;
19+ throw new Error ( "Invalid input: expected an array of arrays" ) ;
2020 }
21- return "Invalid input: expected an array of arrays" ;
21+ return Object . fromEntries ( countryCurrencyPairs ) ;
2222}
2323
2424module . exports = Lookup ;
You can’t perform that action at this time.
0 commit comments