-3

I need to pass the value of the javascript function below to a variable in javascript but its only shows the value in a console. it does not pass the function values (somevar) to the display variables

function functionThatNeedsRowsData(values){
var somevar = values;
// console shows the value
console.log(somevar);

}

//Now display the value of (somevar) in a function and pass it to a variable not working
var display= functionThatNeedsRowsData();
  • Your function doesn't *return* anything. What are you expecting it to return and why? – David May 30 '18 at 17:48
  • Are you just asking about `return`? You want to return a value from `functionThatNeedsRowsData`? What aren't you passing data into that function, and why aren't you returning from it? – Carcigenicate May 30 '18 at 17:48
  • 1
    There is a minimum effort and learning of a language i expect, otherwise i downvote. This question would be avoided by almost **any** javascript tutorial or programming tutorial in general. – ASDFGerte May 30 '18 at 17:50
  • Yeah.. this is something that is handled by learning tools which, if you're not aware of how to return a value from a function, you need to start with. – Stephen May 30 '18 at 17:52

1 Answers1

0

You need to return the value inside the function:

return somevar;
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
  • i have already done that by returning the value but with no luck. the value is asynchronous – Markjames11 May 30 '18 at 18:10
  • @Markjames11: *"the value is asynchronous"* then see [How do I return the response from an asynchronous call?](https://stackoverflow.com/q/14220321/218196) – Felix Kling May 30 '18 at 18:31