What's most recommended?
In a situation that I can use both ways (I can choose, it will work the same way).
What is recommended to do? Create a function or insert the script directly into the JS file?
Basic example:
if(2*5 == 10){
console.log('Verdade!');
}
Or
function conta() {
if(2*5 == 10){
console.log('Verdade!');
}
}
conta();
This was just an example, but it sums up what I want to know.
Once again, reinforcement I know that in certain places I will not be able to create the code directly because it will not make sense and errors will occur, but there are some things so small that in the day to day we have to do , which would like to know which way is recommended, if there is something in the processing speed, etc ...
If this question is based on opinions, sorry!