Greetings!
I am using a small piece of javascript code to count the numbers of items in a comma seperated list. The code looks like this:
let items = inputData.names.split(',');
let length = items.length;
output = [{length: length}];
This works great in cases where the list has at least 1 item. However, sometimes the input field will be empty, and then I run into an error.
Is there a way to modify this code so that if the list contains no elements it returns 0, and counts as normal when the list contains items?
Thanks!
Best answer by ikbelkirasan
View original