index.html 773 B

12345678910111213141516171819202122232425
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. fetch('https://open.er-api.com/v6/latest/USD').then(res => res.json())
  12. .then(data => {
  13. let dataObj = data.rates
  14. for (let key in dataObj){
  15. let button = document.createElement('button')
  16. button.innerHTML = key
  17. button.onclick = () => {alert((+prompt('Введите сумму в '+ key)/dataObj[key]).toFixed(2)+' USD')}
  18. document.body.append(button)
  19. }
  20. })
  21. </script>
  22. </body>
  23. </html>