PricingBlog

Same function, different Args doesn't work, why?

  • uunicode-1282414165952041075

    unicodes

    1 year ago

    the date args return - Mon Jan 01 2024 02:00:00 GMT+0200 (Eastern European Standard Time)

    the date1 args return Invalid Date.

    the input is the same.

    Why this is happening?
    1282414166107488298-Screenshot_2024-09-08_at_21.53.24.png
    1282414166417870919-Screenshot_2024-09-08_at_21.54.49.png
  • lucasg-1282414892929908826

    Lucas G

    1 year ago

    Variables in JS can only have letters
  • Also, to pass in an argument, you have to leave in the args object in the initial function for you to be able to pass in arguments
  • Then in the function, it would be args.date
  • uunicode-1282415201685082193

    unicodes

    1 year ago

    even with this doesn't work.
    1282415201412714567-Screenshot_2024-09-08_at_21.59.35.png
  • lucasg-1282415269112840212

    Lucas G

    1 year ago

    Yeah, you have to leave in the args object
  • uunicode-1282415389900275825

    unicodes

    1 year ago

    Do you mean args.dateStart.date?
  • lucasg-1282415465783754836

    Lucas G

    1 year ago

    differenceTwoDates(args) { ..your code }
  • That args object is passed into the function and that's how you are able to pass arguments in
  • args.dateStart is an item in the args object
  • uunicode-1282416092341600256

    unicodes

    1 year ago

    😅 Sorry Lucas but I do not understand where I'm doing wrong. I have dateStart as arg of the function and I'm calling it in the function.
  • lucasg-1282416209903620219

    Lucas G

    1 year ago

    differenceTwoDates(args) <---
    { ..your code }
  • When you first create the function, it has (args, ctx) in the parameters
  • Leave those in basically
  • That's how the function can access the arguments you define
  • uunicode-1282416697353179229

    unicodes

    1 year ago

    1282416697290129518-Screenshot_2024-09-08_at_22.05.39.png
  • It should be correct now?
  • 1282417114975830027-Screenshot_2024-09-08_at_22.07.30.png
  • understood args.dateStart for selcting the arg I want right?
  • lucasg-1282417236237353001

    Lucas G

    1 year ago

    Right
  • lucasg-1282417547467034685

    Lucas G

    1 year ago

    For it to work in the formula editor, you’d add in return inputDate or whatever other variable you need
  • uunicode-1282417648767860809

    unicodes

    1 year ago

    now it works. OMG!
  • Lucas, I have to give you so many beers 😅
  • lucasg-1282417906151591978

    Lucas G

    1 year ago

    lol
  • uunicode-1282417937579249798

    unicodes

    1 year ago

    For all your help since I joined toddle
  • Thank you Lucas!
  • lucasg-1282418044257308692

    Lucas G

    1 year ago

    You’re welcome