Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myQuote() {
- var input = document.getElementById("userInput").value;
- var path;
- if (input === 'dota') {
- path = 'dotapasta.txt';
- } else if (input === 'ence') {
- path = 'ence.txt';
- } else if (input === 'muu') {
- path = 'other.txt';
- }
- fetch(path)
- .then(result => result.text())
- .then(result => {
- const quotes = result.split('\n')
- //console.log(quotes)
- var nLines = quotes.length;
- var rngNum = Math.floor(Math.random() * nLines);
- var randomLine = quotes[rngNum];
- console.log(randomLine);
- document.getElementById("pasta").innerHTML = randomLine;
- })
- .catch(error => console.error(error))
- document.write('End');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement