0
Hello, everyone. I’m a beginner in the study of Javascript and came across a problem that may be relatively simple. The question is this: I cannot get the numbers sent from the variable "num" to be placed inside the vector "numbers". Always when I type console.log(numbers) the typed numbers appear on the console as "Undefined". My code is incomplete and I can’t move forward without first solving this problem. Note: I left out the code in HTML and CSS, but if you want me to increase it for better view I’ll be posting later.
let numeros = []
function adicionar () {
let num = Number(document.getElementById('cNum').value)
let respF = document.getElementById('respFinal')
if (Number(num) < 1 || Number(num) > 100) {
window.alert('Número Inválido')
} else {
let respNum = document.getElementById('cText')
respNum.innerHTML += `${num}\n`
numeros.push(Number(num).value)
}
It worked. Thank you very much.
– Lucas