Getting Uncaught TypeError: Cannot read properties of null (reading ‘value’)

When trying to console log a variable I declared inside of my event function, my console is shooting back this error

Uncaught TypeError: Cannot read properties of null (reading 'value')
    at HTMLButtonElement.wuTangForever (main.js:16:76)

I tried to make a form, with radio inputs and attributes.

<p>Pepsi or Coke?</p>
<input type="radio" id = "pepsi" name = "soda" value = "1">
<label for = "">Pepsi</label>
<input type="radio" id = "coke" name = "soda" value = "2">
<label for = "">Coke</label>

In my JavaScript, I have the following code:

const sodas = Number(document.querySelector('input[name = soda]:checked').value)

when I console.log(sodas), or do anything, the message error appears. I checked my script tag as I saw others were having the same issue. That did not resolve the issue.

What I want to do is get the value of the checked radio input, turn that value into a number to put into an array.