JS Converting Dollars to Euros?

  • 0
    There is a conversion of hryvnia into euros and dollars, you need to convert dollars into euros. I don't understand how to add
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8" />
      </head>
      <body>
        <script>
          const uahIn = {
            dollar: 28.6,
            euro: 33.29,
            rub: 2.82,
          };
          const dollarIn = {
            euro: 1.16,
          };
          const symbol = {
            dollar: "$",
            euro: "€",
            rub: "₽",
          };
    
          const convertTo = (currency, rubles) => {
            return (rubles / uahIn[currency]).toFixed(2) + symbol[currency];
          };
    
          const run = () => {
            const amount = parseInt(prompt("Введите сумму в гривнях"));
            if (!amount) return alert("Введите действительное число");
    
            const inDollars = convertTo("dollar", amount);
    
            const converted = Object.keys(uahIn).map((currency) =>
              convertTo(currency, amount)
            );
    
            const message = converted.map(
              (item) => `${item} гривня равно ${amount}`
            );
    
            return alert(message.join("\n"));
          };
    
          run();
        </script>
      </body>
    </html>
    JavaScript Sophia Smith, Nov 19, 2019

  • 1 Answers
  • 0
    const convert = (amount, currFrom, currTo) => amount * currencyFrom / currencyTo
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!