I'm trying to get the different numbers and separate them because each number means something in my array. So, I'm getting the value from my input, with the numbers separated by a " ", and trying to split them, so each number belongs to an array in a different position. But, every time that I want to display my array, all the numbers are on [0]. Here's my code:
input = document.getElementById('input');
button = document.getElementById('button');
button.addEventListener('click', findPacientZero);
function findPacientZero(){
var data = input.value;
dadoscortados = data.split(" ")
var dados = new Array;
dados.push(dadoscortados);
var n = dados[0];
var c = dados[1];
document.write(n)
document.write(c)
}
So, when the page displays the 'n', all of the numbers are displayed, while 'c' is undefined. What is wrong?