I'm trying to print a split
, but after passing for
, the first value returns as undefined
, could you tell me what it could be?
function parteTexto() {
var teste;
var texto = document.getElementById("caixa").value;
var textoSplit = texto.split(" ");
for (var i = 0, j = textoSplit.length; i < j; i++) {
teste += textoSplit[i] + "<br/>"
}
document.getElementById("mostrar").innerHTML = teste;
}
<input id="caixa" type="text">
<button onclick="parteTexto()">Analisar</button>
<div id="mostrar"></div>