commit 4b332583762fb3a65395611a9f393ab2985623ff Author: Twoje ImiÄ™ Nazwisko Date: Thu Jun 12 11:27:26 2025 +0200 HTML + JS diff --git a/1 b/1 new file mode 100644 index 0000000..1ed3303 --- /dev/null +++ b/1 @@ -0,0 +1,28 @@ + + + + + + Document + + + + + +

Crypto Price Display

+
+ +
+ + + diff --git a/data/data.json b/data/data.json new file mode 100644 index 0000000..6323cad --- /dev/null +++ b/data/data.json @@ -0,0 +1,5 @@ +{ + "crypto":"ada", + "currency":"usd", + "price":0.66 +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..5d2a6a0 --- /dev/null +++ b/index.html @@ -0,0 +1,27 @@ + + + + + + Document + + + + + +
+ +
+ + + diff --git a/js/script.js b/js/script.js new file mode 100644 index 0000000..dccb8e0 --- /dev/null +++ b/js/script.js @@ -0,0 +1,38 @@ + function renderData(data) { + const container = document.querySelector(".data-container"); + if (container) { + // Clear previous content (if any) + container.innerHTML = ""; + + // Create and append elements for each data field + const cryptoElement = document.createElement("p"); + cryptoElement.textContent = `Crypto: ${data.crypto}`; + container.appendChild(cryptoElement); + + const currencyElement = document.createElement("p"); + currencyElement.textContent = `Currency: ${data.currency}`; + container.appendChild(currencyElement); + + const priceElement = document.createElement("p"); + priceElement.textContent = `Price: ${data.price}`; + container.appendChild(priceElement); + } else { + console.error("Data container not found in the DOM."); + } + } + +function get (url) { + + return fetch (url) + .then ( res => { + return res.json(); + }) + .then (data => { + renderData (data); + console.log(data); + }) + +} + + +get ("./data/data.json");