The logic is:
- create a function called
fontes
which receives as input any sentence
Here is a minimalist example of function
function fontes(frase){
alert(frase); // só para verificar
};
- write this sentence in the body of the page using fonts of different sizes (from 1 to 7)
Here you need to "fetch" the body of the page and store in a variable:
var corpo = document.querySelector('body'); // ou outro elemento que queira
- For this, you must make a loop that will repeat the following TAG by changing only the attribute "size"
Now a for
typical loop is
for (var i = 1; i < 8; i++) {
// fazer qq coisa
}
In this case, inside the loop you have to change the css/style of the text. Here comes a step that is not closed in the question: how to package the phrase? with a div
, <p>
or <span>
? snatch.
If you use a <p>
the code inside the loop could be:
corpo.innerHTML += '<p style="font-size: '+i+'em;">'+frase+'</p>';
Final code:
function fontes(frase) {
var corpo = document.querySelector('body');
for (var i = 1; i < 8; i++) {
corpo.innerHTML += '<p style="font-size: ' + i + 'em;">' + frase + '</p>';
}
};
fontes('Olá mundo!');
What have you tried? Which part didn’t work? What feature are you having problems with (loop? tag? set font size? create the role?)?
– Guilherme Bernal
What is your doubt?
– Felipe Avelar
Ever tried something? If yes put the code, if not try you will only get something by trying and erring!
– Marcelo Diniz
Hello @user8919, welcome to [so.pt]. I recommend a reading on [help] especially on the topic [Ask].
– Caputo
This question seems to be out of context because it is about an exercise in logic which, apparently, the user does not even have a base code to be aided. You just want the "fish ready".
– Bruno Augusto