I´m starting to learn javascript and this is driving me crazy. Here are to different codes that give me the same output.
In this one I don´t define any parameters inside the function
var name = "Alex"
function hellow(){
return "Hellow " + name
}
hellow();
Here I do define the parameter name
var name = "Alex"
function hellow(name){
return "Hellow " + name
}
hellow(name);
Can anybody explain to me why is it needed to define the parameters inside the function? It seems that if you don´t define them it still works.
Thank you