So there's a simple code with vanilla JavaScript.
const button = document.getElementById('btn');const input = document.getElementById('amount');let list = [];button.addEventListener('click', () => { let num = +input.value; if (typeof num === 'number') { list.push(num); console.log(list); } else { console.log('Error. Try again and type in a number'); }})
Why the console.log statement isn't showing up in the console but instead it pushes NaN value to the list?
I tried to use else if instead of just else and passed the following condition: typeof num !== 'number'