js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Build a foreign exchange prototype #419

Closed odv closed 4 years ago

odv commented 4 years ago

You should have one method in your object called "exchange". This method should accept an integer(representing amount in EUR). Your method should return an integer, representing the amount from input converted to GBP.

https://exchangeratesapi.io/

RazvanBugoi commented 4 years ago
function exchange(a) {
    fetch('https://api.exchangeratesapi.io/latest')
    .then((response) => {
    return response.json();
})
    .then((myJson) => {
    console.log(`${myJson.rates.GBP}`);
})}
RazvanBugoi commented 4 years ago
function exchange(euro) {
    fetch('https://api.exchangeratesapi.io/latest')
    .then((response) => {
    return response.json();
})
    .then((myJson) => {
    console.log(`${myJson.rates.GBP * euro}`);
})}