am working on a two paged rating site where am to get information from the main page and use it on the second page and am trying to assign the text content of a clicked div in the main page to rateNumber but for some reason it still gives me the initial empty string assigned to it when I try using it in the second page. pls can anyone help me out here.
here's the js code
const rates = document.querySelectorAll('.rates')
const submit = document.querySelector('.submit')
let rated = document.querySelector('.rated')
let rateNumber = ''
function toggle(){
rates.forEach((rate) =>
rate.classList.remove('active'))
this.classList.add('active')
rateNumber = this.innerText
}
function setRate(){
rated.innerText = rateNumber
}
for (let i = 0; i < rates.length; i++) {
rates[i].addEventListener('click', toggle)
}
this is where am trying to assign it but it's not working and to b honest av ran out of ideas
rates.forEach((rate) =>
rate.classList.remove('active'))
this.classList.add('active')
rateNum = this.innerText
}```