I started a month and a half of studies and the little code below is not writing the name and the points of the two teams informed, only one. If you remove from the code the writing of the data of the first time it normally displays the result of the second. I also replace the document.write in the 'show' function with the console.log and on the console it displays the results of the two teams normally. I read in some articles an information that the document.write method erases the previous information, but I did not understand how this works. If anyone can help me thank you.
<script>
function pulaLinha () {
document.write ("<br");
}
function mostra (frase) {
document.write (frase);
pulaLinha ();
}
function perguntaJogosECalcRes (nomTime) {
var vit = prompt ("Quantos jogos o time " + nomTime + " venceu?");
var emp = prompt ("Quantos jogos o time " + nomTime + " empatou?");
var pontos = (vit * 3) + parseInt (emp, 10);
return pontos;
}
var nomTime1 = prompt ("Qual o nome do primeiro time?");
var nomTime2 = prompt ("Qual o nome do segundo time?");
var ponTime1 = perguntaJogosECalcRes (nomTime1);
var ponTime2 = perguntaJogosECalcRes (nomTime2);
mostra (nomTime1 + " " + ponTime1);
mostra (nomTime2 + " " + ponTime2);
</script>