0

I have a function like this:

function oneFunction()
{
   var onevaribale = $('#onevalue').val();
   var twovariable = $('#twovalue').val();

  //Do something with both variables
  //continue using **onevariable** not noticing the typo as **onevaribale**
}

Now because of the typo, the entire function fails and the location of where the code is run is on an intranet. Luckily, the code has an external js file and I want to assign something like:

var onevariable = onevaribale

How do I go about extending oneFunction to make this change from the external js file?

manlikeangus
  • 421
  • 9
  • 28
  • possible duplicate of [Call variables from one javascript file to another](http://stackoverflow.com/questions/8351265/call-variables-from-one-javascript-file-to-another) – Anwar Jul 07 '15 at 10:14
  • I don't understand. Javascript variables have function scope, meaning they're not accessible from outside the function where they are declared. Do you mean you want to access a variable declared inside a function from outside that function? That's not possible. – Hannes Johansson Jul 07 '15 at 10:18
  • @Zeratops No. It isn't. The variable in that question is in the global scope. This isn't. It is in a function which makes it local – manlikeangus Jul 07 '15 at 10:18
  • @HannesJohansson I would like to change that variable's value. What I want to do is extend that function so that I can do it. – manlikeangus Jul 07 '15 at 10:19
  • You can't. It's not possible to access a local variable from outside that function's environment. – Hannes Johansson Jul 07 '15 at 10:21

0 Answers0