Как получить значение переменой за придели функции
Здраствуйте, подскажите как получить значение переменой userChoiceValue. Переменая обьявленна перед eventListener.
let userChoiceValue
let buttons = document.querySelector('.buttons_play')
buttons.addEventListener('click',(e) => {
let targetItem = e.target
userChoiceValue = targetItem.value
})
console.log(userChoiceValue) //undefined