Я пытаюсь заменить список абзацев только одним случайным абзацем, но по какой-то причине код JavaScript не сработает.
Я попытался переставить переменные после завершения функции, но я не могу понять, что не так.
Вот так начинаются мои HTML-элементы:
<body>
<div id = "quotes">
<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>
И это моя попытка манипулирования DOM:
"use strict";
const quotes = document.querySelectorAll("p");
const randomize = function() {
let num = (Math.floor(Math.random() * Math.floor(quotes.length)) - 1);
let quote = quotes.item(num).innerHTML;
return quote;
}
let randomQuote = randomize();
let passage = document.getElementById('quotes').innerHTML;
passage = randomQuote;
console.log(randomQuote);