-
Notifications
You must be signed in to change notification settings - Fork 0
/
show.js
31 lines (27 loc) · 975 Bytes
/
show.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let array = JSON.parse(localStorage.getItem("news"));
displayNews(array);
function displayNews(array) {
let box = document.getElementById("kd_show");
array.forEach(function (el) {
console.log("el:", el);
let div = document.createElement("div");
let img = document.createElement("img");
img.src = el.urlToImage;
let title = document.createElement("p");
title.innerText = el.title;
let author = document.createElement("p");
author.innerText = `Author: ${el.author}`;
let description = document.createElement("p");
description.innerText = el.description;
let sources = document.createElement("p");
sources.innerText = `Sources: ${el.source.name}`;
let url = document.createElement("p");
url.innerHTML = `For More Information: ${el.url}`;
div.append(img, title, author, description, sources, url);
box.append(div);
});
}
function show() {
localStorage.clear();
window.location.href = "./news.html";
}