Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Custom function created via app script (google sheets) is giving a blank cell. No error is shown

I typed text given in the bottom of this post, in app script. I am getting value for the =Deckel(200,1320) function as 620. For the second function =Dn(200,1320), I am getting a blank cell. What do I do to display value of n in the cell? Thank you.

function Deckel(x,y) {
let d;
for (let n=0; x*n+20 < 580;n++){d=x*(n+1)+20;}
if (d>y) {return "NOT VALID";} else {return d;}  
}

function Dn(x,y) {
let d;
let n;
for (let n=0; x*n+20 < 580;n++){d=x*(n+1)+20;}
if (d>y) {return "NOT VALID";} else {return n;}  
} 

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In your showing script, how about the following modification?

Modified script:

function Dn(x, y) {
  let d;
  let n;
  for (n = 0; x * n + 20 < 580; n++) {
    d = x * (n + 1) + 20;
  }
  if (d > y) {
    return "NOT VALID";
  }
  return n;
}
  • In your showing script, n is used in the loop by declaring let n=0. So, I removed let of let n=0. By this, n is returned.

Reference:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading