Javascript: Functions 2

Functions may also receive parameters and can return values. If the function receives multiple parameters, they are seperated by a comma.


function saySomething(greeting, name){
  alert(greeting + " " + name);
}

saySomething("Hello","Joe");
saySomething("Goodbye","Joe");

/*Or we could create the greeting string and save
  it to a variable*/
  
function saySomething2(greeting, name){
  var myString = greeting + " " + name;
  return myString;
}
var mygreeting = saySomething2("Hello","Bill");