- Joined
- Feb 12, 2020
- Messages
- 2
- Reaction score
- 1
I'm experimenting with a site that cycles through an array of quotes, and I'm trying to make my code more concise. However, when I try to execute this, the button does nothing.
var quotes = ["The human race has one really effective weapon, and that is laughter. - Mark Twain", "Books serve to show a man that those original thoughts of his aren't very new at all. - Abraham Lincoln", "When it is obvious that the goals cannot be reached, don't adjust the goals, adjust the action steps. - Confucious", "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. - Albert Einstein"]
function getquote() {
var y = document.getElementById("demo");
var z = 0;
while (true) {
if (y.innerHTML === quotes[z]) {
z = z + 1;
y.innerHTML = quotes[z];
return;
} else {
z = z + 1;
}
}
}
var quotes = ["The human race has one really effective weapon, and that is laughter. - Mark Twain", "Books serve to show a man that those original thoughts of his aren't very new at all. - Abraham Lincoln", "When it is obvious that the goals cannot be reached, don't adjust the goals, adjust the action steps. - Confucious", "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. - Albert Einstein"]
function getquote() {
var y = document.getElementById("demo");
var z = 0;
while (true) {
if (y.innerHTML === quotes[z]) {
z = z + 1;
y.innerHTML = quotes[z];
return;
} else {
z = z + 1;
}
}
}
Last edited: