Я пытаюсь построить генератор цитат и пытаюсь взять цитаты из коллекции абзацев HTML.
Когда я пытаюсь получить доступ к случайному элементу списка узлов, яполучить все узлы в виде группы абзацев вместо одного абзаца.
Это моя попытка рандомизации:
const quotes = quotesdocument.querySelectorAll("p");
const randomize = function() {
for(quote of quotes) {
let num = (Math.floor(Math.random() * Math.floor(quotes.length)) - 1);
console.log(quotes.item(num));
}
}
И это и отрывок из HTML, который я пытаюсьrandomize:
<p>“<a href="https://theunboundedspirit.com/ananda-coomaraswamy-quotes/">Art</a> is the supreme task and the truly metaphysical activity in this life.”</p>
<p>“Underneath this reality in which we live and have our being, another and altogether different reality lies concealed.”</p>
<p>“We obtain the concept, as we do the form, by overlooking what is individual and actual; whereas nature is acquainted with no forms and no concepts, and likewise with no species, but only with an X which remains inaccessible and undefinable for us.”</p>
<p>“Everything which distinguishes man from the animals depends upon this ability to volatilize perceptual metaphors in a schema, and thus to dissolve an image into a concept.”</p>
<p>“Our destiny exercises its influence over us even when, as yet, we have not learned its nature: it is our future that lays down the law of our today.”</p>
Я ожидал получить только один из этих абзацев, но продолжаю получать их все.
Спасибо за помощь.