我为 FreeCodeCamp 创建的随机报价机几乎完成了,但我想将每个数组项的第二部分斜体。我查了一下,发现没有为我工作。有没有更简单的方法来定位每个项目的第二部分......我认为这可能很困难,但我还很新。谢谢!
var quote = [
"I could die for you. But I couldn't, and wouldn't, live for you." + " — Ayn Rand, The Fountainhead",
"There is not love of life without despair about life." + " — Albert Camus, The Stranger",
"Every act of rebellion expresses a nostalgia for innocence and an appeal to the essence of being." + " — Albert Camus, The Rebel: An Essay on Man in Revolt",
"Man is always prey to his truths. Once he has admitted them, he cannot free himself from them." + " — Albert Camus, The Myth of Sisyphus and Other Essays",
"There is nothing outside of yourself that can ever enable you to get better, stronger, richer, quicker, or smarter. Everything is within. Everything exists. Seek nothing outside of yourself." +
" — Miyamoto Musashi, The Book of Five Rings",
"When one person suffers from a delusion, it is called insanity. When many people suffer from a delusion it is called a Religion." + " — Robert M. Pirsig, Zen and the Art of Motorcycle Maintenance: An Inquiry Into Values",
"The books that the world calls immoral are books that show the world its own shame." + " — Oscar Wilde, The Picture of Dorian Gray",
"Rather than love, than money, than fame, give me truth." + " — Henry David Thoreau, Walden",
"For a friend with an understanding heart is worth no less than a brother" + " — Homer, The Odyssey",
"You have power over your mind - not outside events. Realize this, and you will find strength." + " — Marcus Aurelius, Meditations",
"The happiness of your life depends upon the quality of your thoughts." + " — Marcus Aurelius, Meditations",
"Everything we hear is an opinion, not a fact. Everything we see is a perspective, not the truth." + " — Marcus Aurelius, Meditations",
"It's the job that's never started as takes longest to finish." + " — J.R.R. Tolkien, The Lord of the Rings",
"History is a wheel, for the nature of man is fundamentally unchanging. What has happened before will perforce happen again." + " — George R.R. Martin, A Feast for Crows" ,
"The first method for estimating the intelligence of a ruler is to look at the men he has around him." + " — Niccolò Machiavelli, The Prince",
"Time makes more converts than reason." + " — Thomas Paine, Common Sense",
];
function showQuote(num) {
return quote[num];
}
$(document).ready(function() {
$('#newQuote').click(function() {
$('#quoteHere').html(showQuote(Math.floor(Math.random() * 16)));
});
});