Let's say I need to loop through a list of items a...
# suitescript
c
Let's say I need to loop through a list of items and perform various actions based on inputs, the code is much cleaner if a separate the actions into their own functions, I would need to pass the counter into the functions as a param. Would anyone here say that is bad practice? i.e., for (let i = 0: i < something.length; i++) and pass the i variable into a function?
c
I'd argue that it's harder to read if you're having to scroll elsewhere to look at each function body individually. I guess it depends whether the code in the functions is reused identically in other places
c
I don't believe the code will be reused at all
I guess it's better to have a rather long function then?
Actually - no - that's bad. It's much harder to test a function that does too many things, you should be breaking your code down into logical operations/functions for cohesiveness and testability.
That's for being a sounding board!
c