# JavaScript doesn't run with empty parameter? Possible Bug?

**URL:** <https://community.weweb.io/t/javascript-doesnt-run-with-empty-parameter-possible-bug/7295>\
**Category:** Developer corner\
**Created:** [February 27, 2024, 2:40pm UTC](https://community.weweb.io/t/javascript-doesnt-run-with-empty-parameter-possible-bug/7295 "2024-02-27T14:40:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benFortunato](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@benFortunato](https://community.weweb.io/u/benFortunato)\
**Post date:** [February 27, 2024, 2:40pm UTC](https://community.weweb.io/t/javascript-doesnt-run-with-empty-parameter-possible-bug/7295/1 "2024-02-27T14:40:30Z")

</div>

I have a javascript function with an if else statement to return a value if the input parameter is blank. It doesn’t appear to be returning anything, unless there is something wrong with my javascript.

When I set the test variable to empty, it doesn’t return false just an empty string. I wrapped this function in a conditional so i get the output i want in case of a null value but it should run even with a null parameter input

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/c/c5a16f1867201a8022b33ea995bd7364a4895be9.png)

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [February 27, 2024, 6:32pm UTC](https://community.weweb.io/t/javascript-doesnt-run-with-empty-parameter-possible-bug/7295/2 "2024-02-27T18:32:07Z")

</div>

in your screenshot the test array is not empty, has one element of value `0` and the result seems correct.  
have you tried with an empty array `[]` as input?

---

<div class="post-metadata">

**Author:** ![benFortunato](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@benFortunato](https://community.weweb.io/u/benFortunato)\
**Post date:** [February 27, 2024, 7:51pm UTC](https://community.weweb.io/t/javascript-doesnt-run-with-empty-parameter-possible-bug/7295/3 "2024-02-27T19:51:25Z")

</div>

I did. Rather not an empty array but just nothing. Then it outputs nothing even though the if statement should check for an empty vairable and return a flag.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [February 27, 2024, 9:02pm UTC](https://community.weweb.io/t/javascript-doesnt-run-with-empty-parameter-possible-bug/7295/4 "2024-02-27T21:02:03Z")

</div>

can’t say for sure without seeing the code, but I think it’s not returning anything because it throws an error when accessing `recordIds.length` because null doesnt have length. Check your logs for confirmation. If that’s the case you need to check that the input variable it’s not empty before moving on

---

<div class="post-metadata">

**Author:** ![benFortunato](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@benFortunato](https://community.weweb.io/u/benFortunato)\
**Post date:** [March 4, 2024, 2:25pm UTC](https://community.weweb.io/t/javascript-doesnt-run-with-empty-parameter-possible-bug/7295/5 "2024-03-04T14:25:37Z")

</div>

That makes sense, it not an empty array its just an empty variable, ie undefined. Thanks!
