Skip to content

Commit

Permalink
Ensured all tests are passed
Browse files Browse the repository at this point in the history
  • Loading branch information
olarotseyi committed Aug 1, 2022
1 parent c0e287c commit 41e66f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ class CurrencyConverter {
}

rates(){
if(this.currencyFrom === this.currencyTo)
return new Promise((resolve, _) => {resolve(this.currencyAmount) })
else
if (this.currencyFrom === this.currencyTo) {
return new Promise((resolve, _) => {resolve(1) })
} else {
let currencyPair = this.currencyFrom.toUpperCase() + this.currencyTo.toUpperCase();
if (currencyPair in this.ratesCache)
return new Promise((resolve, _) => {
resolve(this.ratesCache[currencyPair]);
});
else
if (currencyPair in this.ratesCache) {
return new Promise((resolve, _) => {
resolve(this.ratesCache[currencyPair]);
});
} else {
return got(`https://www.google.co.in/search?q=${this.currencyFrom}+to+${this.currencyTo}+&hl=en`)
.then((html) => {
return cheerio.load(html.body)})
Expand All @@ -287,10 +287,12 @@ class CurrencyConverter {
}
return parseFloat(rates)
})
}
}
}

convert(currencyAmount){
if(currencyAmount !== undefined){
if (currencyAmount !== undefined){
this.amount(currencyAmount)
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 41e66f2

Please sign in to comment.