0

I have following methods:

function do(name){}


function name(text){    
      alert(text);
}

what if I want to make something like:

do(name('123456789')) {}

Is that possible and how I manage to do that?

user3133542
  • 1,695
  • 4
  • 21
  • 42
  • 1
    As in [Pass a JavaScript function as parameter](http://stackoverflow.com/questions/13286233/pass-a-javascript-function-as-parameter) ? – Alex K. Apr 10 '17 at 11:22
  • Can you at-least write correct pseudo code `do(name('123456789')) {}` – Satpal Apr 10 '17 at 11:22

2 Answers2

3

Do is a Reserved word, try this:

function make(nameFunction,argFunction){
  nameFunction(argFunction);
}

make(name,"works");

function name(text){    
      console.log(text);
}
Rafael Umbelino
  • 771
  • 7
  • 14
2

You just return value from function that you are going to pass as parameter to other function and now value of parameter in that function is returned value from other function that you passed.

function x(param){
  return param + 1;
}

function y(param){    
  return param + 1;
}

console.log(y(x(1)))
Nenad Vracar
  • 118,580
  • 15
  • 151
  • 176