Kevin Powell - CommunityKP-C
Kevin Powell - Community3y ago
5 replies
Nox

Variable function parameter

I'm trying to figure out how to pass a parameter in a for loop, like so:
for (let i = 0; i < mainhaul[0].length; i++) { createSingle( co2cols, 'Distance', distanceFix(mainhaul[0][i].emissions.distances.{type}._) ); }

This loop sits in a function, which gets type as a parameter, that I'm trying to use to alter the distanceFix parameter, but I can't figure out to do it, or if I even can do what I'm trying to. A little worried I've fallen into an xy trap.

Basically, the question is, is there syntax to allow me to insert a variable into distanceFix to replace {type}?

I'm not even sure if I'm making sense at this point, feeling a little in over my head :p
Was this page helpful?