├── styles.css ├── .gitattributes ├── README.md ├── main.js └── index.html /styles.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background-color: antiquewhite; 3 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Currency Converter 2 | Source code for currency converter project on CodeWithHarry YouTube channel 3 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | console.log("Main.js working") 2 | 3 | const populate = async (value, currency) => { 4 | let myStr = "" 5 | url = "https://api.currencyapi.com/v3/latest?apikey=cur_live_7UStkUqQNBmahSoy8K635tE3Sjr5fK1UVPmVloZ2&base_currency=" + currency 6 | let response = await fetch(url) 7 | let rJson = await response.json() 8 | document.querySelector(".output").style.display = "block" 9 | 10 | for (let key of Object.keys(rJson["data"])) { 11 | myStr += ` 12 | ${key} 13 | ${rJson["data"][key]["code"]} 14 | ${Math.round(rJson["data"][key]["value"] * value)} 15 | 16 | ` 17 | } 18 | const tableBody = document.querySelector("tbody"); 19 | tableBody.innerHTML = myStr; 20 | 21 | } 22 | const btn = document.querySelector(".btn") 23 | btn.addEventListener("click", (e) => { 24 | e.preventDefault() 25 | const value = parseInt(document.querySelector("input[name='quantity']").value); 26 | const currency = document.querySelector("select[name='currency']").value 27 | populate(value, currency) 28 | }) 29 | 30 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Currency Converter - Convert your currency 8 | 9 | 141 | 142 | 143 | 144 | 152 | 153 |
154 |

Choose a currency to convert

155 |
156 | 157 | 158 | 159 | 164 | 165 | 166 |
167 |
168 |

Here is your converted values in different currencies

169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 |
CurrencyCodeValue
181 |
182 |
183 | 186 | 189 | 190 | 191 | 192 | --------------------------------------------------------------------------------