Please a javascript project

Please a javascript project

<!DOCTYPE html>

<!DOCTYPE html>

<html lang="en">

 <head>

  <meta charset="UTF-8" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />

  <meta http-equiv="X-UA-Compatible" content="ie=edge" />


  <title>Mini App</title>


  <style>

   body{

    background: #fff;

   }

  </style>

 </head>

 <body>

  <h2>GetWet App</h2>

  <div class="select-currency select">

   <select class="select-text">

    <option value="">disabled</option>     

    <option value="">Selected</option>

    <option value="">Choose Currency</option>


   </select>

  </div>

  <button class="btn">Convert</button>

  <div class="conversion mdc-elevation--z3">

    

  </div>

  <div class="message">

    

  </div>

  <script>

    

   const currencies = [{

    id: 'USD', name: 'US Dollars'

   }, {

    id: 'UGX', name: 'Ugandan Shillings'

   }, {

    id: 'KES', name: 'Kenyan Shillings'

   }, {

    id: 'GHS', name: 'Ghanian Cedi'

   }, {

    id: 'ZAR', name: 'South African Rand'

   }];

    

      const apiBase = 'https://free.currencyconverterapi.com/api/v6/';

   const api = (currency) => `

    ${apiBase}convert?q=${currency}_NGN&compact=ultra

 `;

    

   const toast = (msg) => {

    const toastr = document.querySelector('.messages');

    if(!toastr) return;

     

    toastr.textContent = msg;

    if(!toastr.classList.contains('on')) {

     toastr.classList.add('on');

    }

   };

    

   const doneToasting = () => {

    const toastr = document.querySelector('.messages');

    if(!toastr) return;

     

    toastr.textContent = '';

    toastr.classList.remove('on');

   };

    

   const conversionSucceeded = (apiResponse) => {

    if(!apiResponse) {

     toast(`nothing to display ...`);

     return;

    }

     

    const [value] = Object.values(apiResponse)

     

    const btn = document.querySelector('button');

    btn.removeAttribute('disabled');

     

    const display = document.querySelector('.conversion');

    const formatter = new Intl.NumberFormat(

     'en-NG', { style: 'currency', currency: 'NGN' }

    );

     

    display.textContent = formatter.format(value);

    doneToasting();

   };

    

   // declare populateCurrencies here    

    

   const getSelectedCurrency = () => {

    // here, determine and return the selected value 

    // of the SELECT element

   };

       

   const convert = (event) => {

    toast(`preparing to convert ...`);

     

    const btn = event ? 

       event.target : document.querySelector('button');

     

    const selected = getSelectedCurrency();

     

    if(!selected || selected.trim() === '' 

      || !currencies.map(c => c.id).includes(selected)) return;

     

    btn.setAttribute('disabled', 'disabled');

    toast(`converting ...`);

     

    const endpoint = api(selected);

     

    // make a GET fetch call to the endpoint

    // variable declared above, convert the response to JSON,

    // then call conversionSucceeded and pass the JSON data to it

     

   };

    

   const startApp = () => {

    // call populateCurrencies here

     

    // add a click listener to the button here

   };


   startApp();

  </script>

 </body>

</html>

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

JavaScript Tutorial: if-else Statement in JavaScript

This JavaScript tutorial is a step by step guide on JavaScript If Else Statements. Learn how to use If Else in javascript and also JavaScript If Else Statements. if-else Statement in JavaScript. JavaScript's conditional statements: if; if-else; nested-if; if-else-if. These statements allow you to control the flow of your program's execution based upon conditions known only during run time.

How to Retrieve full Profile of LinkedIn User using Javascript

I am trying to retrieve the full profile (especially job history and educational qualifications) of a linkedin user via the Javascript (Fetch LinkedIn Data Using JavaScript)

Java vs. JavaScript: Know The Difference

Java vs. JavaScript: Know the Difference, Java vs. JavaScript: What's the Difference? Java vs. JavaScript: Major Similarities and Differences. pros and cons of JavaScript and Java.