Skip to main content

Empty input in a function

Tutorial on an empty input in a function.

I was doing this challenge on Code Wars where I had to "Return null if param is null or array is empty."

This caused me some trouble and took me a while to figure out how to write a condition for an empty input in a function.

This is something I came up with and it worked for me:

It was interesting for me to find a way to write it this way where basically it test if the value has no length which seem pretty obvious right now.

Comments