Imagine you have the following arrays at your disposal:
const array1 = ["a1", "b1", "c1", "d1"],
array2 = ["a2", "b2"],
array3 = ["a3", "b3", "c3"]
Do any special functions like ramda exist that can simplify this specific situation, allowing you to work with one or more arrays?
const nestedMap = map => {
const result = []
for(let item1 of array1)
for(let item2 of array2)
for(let item3 of array3)
result.push(map(item1, item2, item3))
return result
}
The complete function would look something like this:
// Sample usage
nestedMap((item1, item2, item3) => `${item1} ${item2} ${item3}`, array1, array2, array3)
I'm hoping to find a solution without having to start from scratch.
Note: You don't necessarily need to use ramda; vanilla JavaScript or other libraries are also acceptable. I just mentioned ramda as it has many functions that could potentially help with this issue