Karolina Ticha Karolina Ticha - 11 months ago 58
Javascript Question

Purpose of JavaScript function parameter

I can't understand the purpose of parameters in JavaScript functions. Let's say:

function sayWelcome(name) {
document.write("Welcome to our page " + name);

What thing should do that name on first line? Why I should use that?


Lets say you've got an automatic teller machine (atm). The atm wants to know who you are and what you want to return your money. So the atm function would look like

function atm(name, pin, money){
   if(all true){
      return money;

And the user would do:

atm("john doe", 1234, 1000);