0
I created a function pularLinha()
so you don’t have to keep repeating <br>
constantly, however to make the line jump more than once inside the function mostra()
, I call pularLinha()
twice.
There I think and if it were necessary to jump 5 in 5 lines, I would call the same function 5 times within the function mostra()
? That would look awful!
I tried to put an implementation to improve the code and stay functional, but I could not.
let pulaLinha = function (){
document.write("<br>");
};
let mostra = function(frase){
document.write(frase);
pulaLinha(); pulaLinha();
}
let ano = 2012;
mostra("Eu nasci em : " + (ano - 25));
mostra("Adriano nasceu em : " + (ano - 26));
mostra("Paulo nasceu em : " + (ano - 32));
If you need to repeat the same thing over and over again, use a
for
. Another detail, to declare functions, simply dofunction mostra(frase) { etc}
. In that case there’s no point in doingmostra = function(etc..)
: https://answall.com/q/13364/112052 | https://stackoverflow.com/a/33040926– hkotsubo
Another thing I think is wrong there is that you keep giving one Document.write on top of another, Document.write overwrites all html.
– LeAndrade