1
I’m trying to print on inner one split
, however, after passing through the for
, the first value returns as undefined
, could tell me what it might 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>
Thank you! That’s right!
– Uchiha