I have a problem with a  function Execution ,   I  call a function   inside another function but it appears an error like &quot;Invoice is not defined&quot; I tried  some methods but didnt' work , also some value  from objects not appearing on table  when i want to post Any solution for this ? It will helps me so much Thanks   let bill = [  {    name : "Sandra",      price : 50,      payment : "visa",      cardnumber:"1234 xxxx xxxx xxxx"  },   {    name : "Johnson",      price : 200,      payment : "master",      cardnumber:"1234 xxxx xxxx xxxx"  },  {    name : "Maria",      price : 500,      payment : "master",      cardnumber:"1234 xxxx xxxx xxxx"  },  {    name : "Bueno",      price : 1000,      payment : "american-express",      cardnumber:"1234 xxxx xxxx xxxx"  }, ]  let get  = document.querySelector(".get"); let first =  document.querySelector(".first"); let second =  document.querySelector(".second"); let third =  document.querySelector(".third"); let counter = document.querySelector("b"); let add = 0; let table = document.querySelector("table"); table.style.display="none"; let fourth=  document.querySelector(".fourth"); let result = document.querySelector("h2"); let reven = document.querySelector("strong");  GetBills = () =&gt; {   get.addEventListener("click" , ()=&gt; {       table.style.display = "flex";     UpdateDOM();     let invoice= bill[Math.floor(Math.random()* bill.length)];     let store = parseInt(bill[0].price) + parseInt(bill[1].price +                    parseInt(bill[2].price + parseInt(bill[3].price)));       add++;     if(add&gt;bill.length) {       add--;            result.innerHTML = `You have only ${bill.length} Bills,&lt;/br&gt;buy to store to add more` ;         reven.textContent = `Total Revenue from bills:${store} $ `;     } else {       console.log("Very Good")     }   }) } GetBills();  UpdateDOM = () =&gt; {   GetBills();     counter.innerHTML=add;   first.innerHTML =  invoice.name;   second.innerHTML = invoice.price;   third.innerHTML =  invoice.payment;   fourth.innerHTML =  invoice.cardnumber;    if(get) {     console.log("Invoice Transacted")   } else {     console.log("Invoice not transacted")   } }  console.log(UpdateDOM()); body {  font-family:"Lato",sans-serif; display : flex; align-items:center; justify-content:center; background-color:#f4f4f4; flex-direction:column; }  .get { border:1px solid lightgray; padding:10px 50px; background-color:white; box-shadow:2px #fff; margin:20px 0; } &lt;!DOCTYPE html&gt; &lt;html&gt;   &lt;head&gt;     &lt;meta charset="utf-8"&gt;     &lt;meta name="viewport" content="width=device-width"&gt;     &lt;title&gt;repl.it&lt;/title&gt;     &lt;link href="style.css" rel="stylesheet" type="text/css" /&gt;   &lt;/head&gt;   &lt;body&gt;     &lt;h1&gt; Get latest Bill &lt;/h1&gt; &lt;button class="get"&gt;Get&lt;/button&gt; &lt;table &gt;   &lt;tr&gt;     &lt;th&gt;Name&lt;/th&gt;     &lt;th&gt;Price&lt;/th&gt;      &lt;th&gt;Payment&lt;/th&gt;             &lt;th&gt;Card Number&lt;/th&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="first"&gt;&lt;/td&gt;     &lt;td class="second "&gt;&lt;/td&gt;     &lt;td class="third"&gt;&lt;/td&gt;             &lt;td class="fourth"&gt;&lt;/td&gt;    &lt;/tr&gt;     &lt;/table&gt;     &lt;h1&gt;     All Bills: &lt;b&gt;0&lt;/b&gt;;     &lt;h2&gt;       Result     &lt;/h2&gt;     &lt;h3&gt;     &lt;strong&gt;&lt;/strong&gt;     &lt;/h3&gt;     &lt;/h1&gt;     &lt;script src="script.js"&gt;&lt;/script&gt;   &lt;/body&gt; &lt;/html&gt;
122
What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally?
115908
Suppose the following function:  CREATE FUNCTION [dbo].[ufnTest]() RETURNS TABLE AS RETURN SELECT 1 AS Nr   My actual function will select actual data from many different tables. I (mostly) understand the risks of using nolock hints, and decided that in this case I actually want them. So I try to call above function like this:  SELECT * FROM [dbo].[ufnTest]() WITH(NOLOCK)   However,  with the following message:     Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.   The tips for fixing this error are not relevant. Perhaps this table hint isn't available for table valued functions then?  There are several alternatives I'd consider. One is to use the hint on all tables in my select query, but I'd prefer not to as (a) I'll have to remember this whenever I change the function around and (b) it's repetitive. Another alternative would be to SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, but a downside is that I don't quite know how to set it back to wat it was before (and statements after the select from my TVF should have the original isolation level).  So, I'd prefer to make WITH (NOLOCK) for a select from a table valued function work. Is this possible?
79759
Spivak's Calculus 4th edition, Chapter 3 Functions, Page 47:  DEFINITION: A function is a collection of pairs of numbers with the following property: if (a,b) and (a,c) are both in the collection, then b = c; in other words, the collection must not contain two different pairs with the same first element.  He continues:  This is our first full-fledged definition, and illustrates the format we shall always use to define significant new concepts. These definitions are so important (at least as important as theorems) that it is essential to know when one is actually at hand, and to distinguish them from comments, motivating remarks, and casual explanations. They will be preceded by the word DEFINITION, contain the term being defined in boldface letters, and constitute a paragraph unto themselves.  Ok got it. Fast forward to the problem set, I'm up to problem 25)  25) Find a function f(x) such that g(f(x)) = x for some g(x), but such that there is no function h(x) with f(h(x)) = x  I asked about this on MSE (see ), and after much discussion came to the resolution that the problem 25 is impossible given the above definition of a function. In summary, the problem is that in order to find f(x), you need to choose f(x) to be a non-surjective function, which requires the concept of codomain. However the above definition does not include the concept of codomain, only domain and image, hence it is impossible. My question is: What was Spivak thinking (and I mean literally)? How did Spivak intend for us to solve this problem? Is it an error on his part? Or is there a way to intuitively infer from the above definition that functions must be specified a codomain (codomain, not image) in order to be defined? If I had the solutions book to Calculus 4th Edition, this would greatly help answer my question, but I can't find it anywhere for free.
22444
Need help in adding another function using the below script. I would like to have a timestamp "start" and "end" on two different columns, whenever the other two separate columns are edited. Based on the below script, I could only have one time stamp, from one column which is the column 2 and time stamp on column 10.  function onEdit()  {  var s = SpreadsheetApp.getActiveSheet();  if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet    var x = s.getActiveCell();    if( x.getColumn() == 2 ) { //checks the column      var nextCell = x.offset(0, +8);      if( nextCell.getValue() === '' ) //is empty?        var time = new Date();      time = Utilities.formatDate(time, "GMT", "hh:mm");        nextCell.setValue(time);    };  }; }
24042
To make a JavaScript class with a public method I'd do something like:  function Restaurant() {}  Restaurant.prototype.buy_food = function(){    // something here }  Restaurant.prototype.use_restroom = function(){    // something here }   That way users of my class can:  var restaurant = new Restaurant(); restaurant.buy_food(); restaurant.use_restroom();   How do I create a private method that can be called by the buy_food and use_restroom methods but not externally by users of the class?  In other words, I want my method implementation to be able to do:  Restaurant.prototype.use_restroom = function() {    this.private_stuff(); }   But this shouldn't work:  var r = new Restaurant(); r.private_stuff();   How do I define private_stuff as a private method so both of these hold true?  I've read  a few times but it doesn't seem like "private" methods can be called by public methods and "privileged" methods can be called externally.
83765
This AJAX function gets called on a click:  $.ajax({             url: 'site/ajax.php',             data: {id: $('section#single article input:last-of-type').attr('value'), cote: 'like'}         }).done(function(html) {}   It passes the ID of the post (which is contained in a hidden input) for function get_post_meta() that is located in ajax.php. This is what AJAX.php looks like:  $cote = get_post_meta($_GET['id'], 'cote', true); if($_GET['cote'] == 'like') {     $newCote = $cote++;     update_post_meta($_GET['id'], 'cote', $newCote); } else {     $newCote = $cote--;     update_post_meta($_GET['id'], 'cote', $newCote); }   It is suppose to update the custom post's "cote" field, but the problem is that function get_post_meta() is undefined in ajax.php. This is the error message:  Fatal error: Call to undefined function get_post_meta() in /home2/electro/public_html/beta... on line 2
81419
Is it possible to use the =today() function (or something else) to insert the current date but then not update each time the file is opened?  I want to create a numbers template for my invoices. I'd like it to auto fill invoice date and date due then, when I save the document, store the values, not the function.
81559
Unfortunately, as a new user I am not allowed to comment. This is why I need to do a new post regarding to this topic:   This is my code in Google Sheets Script:  function onEdit(e) {   if (e.range.getSheet().getSheetName() == 'Tabellenblatt1' &amp;&amp; e.range.getColumn() == 1) {     e.range.offset(0,1).setValue(new Date());   } }   It works perfectly when I enter data in cell 1 manually, but when data is added via API (in this case when data is added via Zapier) it does not work. Anybody can give me a hint why?
83885
What exactly makes a function well-defined? I have seen some proofs but they are too hand-wavy and I couldn't understand exactly what a well-defined function is.
47347
What is the general reason for functions which can only be defined implicitly?   Is this because they are multivalued (in which case they aren't strictly functions at all)?   Is there a proof?   Clarification of question.  The second part has been answered with example of single value function which cannot be given explicitly. The third part was automatically answered because there can't be a proof that necessarily implicit functions are all multivalued by way of the example of one that wasn't.    I don't think that the first part has yet been addressed. Stating that the answer can't be expressed in "elementary functions" seems tantamount to saying that it a necessarily implicit function, unless I'm missing something about the definition of "elementary functions". Such answers seem to imply that the equation could be solved in terms of "non-elementary" functions.If this is correct than I need to find out about them and how they could be used to calculate the dependent variable solely in terms of the independent one (my notion of an explicit function). This would seem to violate the notion of a function which could only be defined implicitly. I am also not concerned with whether or not the solution is closed or open form (by which I mean finite number of terms or infinite).
111110
I'm a bit confused as to how to get two method to call each other (i.e., have A() call B() and B() call A()). It seems that F# only 'sees' the method after it's been encountered in code, so if it hasn't, it just says value or constructor has not been defined.  Am I missing something very basic here?
4613
How can I create or use a global variable in a function?  If I create a global variable in one function, how can I use that global variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?
19506
I have a function that is declared and defined in a header file. This is a problem all by itself. When that function is not inlined, every translation unit that uses that header gets a copy of the function, and when they are linked together there are duplicated. I "fixed" that by making the function inline, but I'm afraid that this is a fragile solution because as far as I know, the compiler doesn't guarantee inlining, even when you specify the "inline" keyword. If this is not true, please correct me.  Anyways, the real question is, what happens to static variables inside this function? How many copies do I end up with?
15717
I'd like to do something like this:  &gt;&gt; foo = @() functionCall1() functionCall2()   So that when I said:  &gt;&gt; foo()   It would execute functionCall1() and then execute functionCall2().  (I feel that I need something like the )  EDIT:  functionCall1 and functionCall2 are not necessarily functions that return values.
62479
I am doing , and am having a few problems with function notation. I understand the form f(x).  What does the form f: x ↦ y mean? Could you also give one or two examples?  And, if possible, state your source. Thank you.
80203
This error should be a simple one but I cant seem to make it work. The problem lies in the fact that this very same code works earlier in the program. I don's see any reason for it to be sending an error on this instance and not the four previous ones. Reference the code below, and feel free to provide any criticism you may have as it should make me better. If it matters, I am using Sharp Develop 2.2.  Here is an example of the code that works:  void calc2Click(object sender, EventArgs e) {     if (!String.IsNullOrEmpty(tb2_fla.Text) &amp; String.IsNullOrEmpty(tb2_e.Text) | String.IsNullOrEmpty(tb2_fla.Text) &amp; String.IsNullOrEmpty(tb2_e.Text) | String.IsNullOrEmpty(tb2_e.Text))     {         MessageBox.Show("Enter either kVA and Voltage or FLA and Voltage", "Invalid Data Entry", MessageBoxButtons.OK);     }                 if (!String.IsNullOrEmpty(tb2_kva.Text) &amp; !String.IsNullOrEmpty(tb2_e.Text))     {              decimal x, y, z;             x = decimal.Parse(tb2_kva.Text);                   y = decimal.Parse(tb2_e.Text);             z = (x * 1000) / (1.732050808m * y); //the m at the end of the decimal allows for the multiplication of decimals                 tb2_fla.Text = z.ToString();             tb2_fla.Text = Math.Round(z,2).ToString();     }         else     {         if (!String.IsNullOrEmpty(tb2_fla.Text) &amp; !String.IsNullOrEmpty(tb2_e.Text))     {              decimal x, y, z;             x = decimal.Parse(tb2_fla.Text);                   y = decimal.Parse(tb2_e.Text);             z = (x * y * 1.732050808m) / 1000; //the m at the end of the decimal allows for the multiplication of decimals               tb2_kva.Text = Math.Round(z,2).ToString();      }   Here is the example of the code that sends the error in the subject line of this post:  void Calc4Click(object sender, EventArgs e) {         if (!String.IsNullOrEmpty(tb4_fla.Text) &amp;&amp; String.IsNullOrEmpty(tb4_e.Text) || String.IsNullOrEmpty(tb4_kw.Text) &amp; String.IsNullOrEmpty(tb4_e.Text) || String.IsNullOrEmpty(tb4_e.Text))         {   //If values are entered improperly, the following message box will appear         MessageBox.Show("Enter either FLA and Voltage or kW and Voltage", "Invalid Data Entry", MessageBoxButtons.OK);         }              if (!String.IsNullOrEmpty(tb4_fla.Text)&amp;&amp; !String.IsNullOrEmpty(tb4_e.Text)&amp;&amp; String.IsNullOrEmpty(tb4_kw.Text))         {//If the user eneters FLA and Voltage calculate for kW              decimal x, y, z;             x = decimal.Parse(tb4_fla.Text);             y = decimal.Parse(tb4_e.Text);             z = (x*y)*(.8 * 1.732050808m);             tb4_kw.Text = Math.Round(z,0).ToString();          }                         if (!String.IsNullOrEmpty(tb4_kw.Text) &amp;&amp; !String.IsNullOrEmpty(tb4_e.Text) &amp;&amp; String.IsNullOrEmpty(tb4_fla.Text))         {;//If the user enters kW and Voltage calculate for FLA             decimal x, y, z;             x = decimal.Parse(tb4_kw.Text);             y = decimal.Parse(tb4_e.Text);             z = (1000 * x)/(y * 1.732050808m)* .8;             tb4_fla.Text = Math.Round(z,0).ToString();         }      }   I appreciate any help that I can get.  Thank you.
8344
I'm working with a bit of html and Javascript code that I've taken over from someone else. The page reloads a table of data (via an asynchronous request) every ten seconds, and then re-builds the table using some DOM code. The code in question looks something like this:  var blah = xmlres.getElementsByTagName('blah'); for(var i = 0; i &lt; blah.length; i++) {     var td = document.createElement('td');     var select = document.createElement('select');     select.setAttribute("...", "...");     select.onchange = function() {         onStatusChanged(select, callid, anotherid);     };     td.appendChild(select); }   When the onchange event is fired for a &lt;select&gt; element however, it seems like the same values are being passed to the onStatusChanged() method for every &lt;select&gt; in the table (I've verified that in each iteration of the loop, callid and anotherid are being given new, distinct values).   I suspect this is occuring because of the nature of how I am setting the event handler, with the select.onchange = function() syntax. If I understand how this is working correctly, this syntax sets a closure for the onchange event to be a function which refers to these two references, which end up having a final value of whatever they are set to on the last iteration of the loop. When the event fires, the value referenced by callid and anotherid is the value set in the last iteration, not the value set at the individual iteration.  Is there a way that I can copy the value of the parameters I am passing to onStatusChanged()?  I've changed the title to better reflect the question and the accepted answer.