For some reason, I get “Uncaught TypeError: Cannot set property ‘innerText’ of null at” when gr1 and other variables are supposed to be changed into an item from an array
let rasa = document.getElementById("prvi")
let rase = ["jedna", "druga", "treca", "cetvrta"]
let gr1 = document.getElementById("#gr1")
let gr2 = document.getElementById("#gr2")
let dl1 = document.getElementById("#dl1")
let dl2 = document.getElementById("#dl2")
let niz = ["jd","dv","tr","ct","pt","s"]
function dd(){
rasa.innerText = rase[Math.floor(Math.random()*4)]
gr1.innerText = niz[Math.floor(Math.random()*6)]
gr2.innerText = niz[Math.floor(Math.random()*6)]
dl1.innerText = niz[Math.floor(Math.random()*6)]
dl2.innerText = niz[Math.floor(Math.random()*6)]
}
Same as the one I posted up but I have removed “#” from the getElementById() so it looks like this now
let rasa = document.getElementById("prvi")
let rase = ["jedna", "druga", "treca", "cetvrta"]
let gr1 = document.getElementById("gr1")
let gr2 = document.getElementById("gr2")
let dl1 = document.getElementById("dl1")
let dl2 = document.getElementById("dl2")
let niz = ["jd","dv","tr","ct","pt","s"]
function dd(){
rasa.innerText = rase[Math.floor(Math.random()*4)]
gr1.innerText = niz[Math.floor(Math.random()*6)]
gr2.innerText = niz[Math.floor(Math.random()*6)]
dl1.innerText = niz[Math.floor(Math.random()*6)]
dl2.innerText = niz[Math.floor(Math.random()*6)]
}