Lorem Ipsum based in Lord Of The Rings coded in JS and the help of Axios library.
All of the LOTR quotes come from a JSON file I built and hosted in here .
Here is some sample code (almost the whole app tbh):
function getRandomQuote (res){
const times = iteration.value;
const arr = res.data.quotes;
cleanPrevious();
for(let i = 0; i < times; i++){
const random = Math.floor(Math.random() * arr.length);
const randomQuote = arr[random];
addElement(randomQuote);
}
}
function addElement(content){
const paragraph = document.createElement("p");
const paraText = document.createTextNode(content);
paragraph.appendChild(paraText);
container.appendChild(paragraph);
}
function cleanPrevious(){
while (container.firstChild) {
container.removeChild(container.firstChild);
}
}