Let's say I have this function
function myFunction(a, b, c) {
... code here ...
}
Now I want to call it multiple times with several different arguments each time:
myFunction('sky', 'blue', 'air');
myFunction('tree', 'green', 'leaf');
myFunction('sun', 'yellow', 'light');
myFunction('fire', 'orange', 'heat');
myFunction('night', 'black', 'cold');
How can I merge all those calls in just one?
I know how to do it with iterations or forEach when there is just one argument, but I can't figure out how to do it with various non-numerical arguments.
myFunction, not without changing howmyFunctionworks. Depending on where the values come from, you can certainly use a loop to only code a single call tomyFunction.