The elements of those arrays are objects. Concatenating those with a string is telling JS to coerce those to strings, which comes our as [object Object].
I’m not sure what you are trying to accomplish. Merge can mean different things. What do you expect the result to look like?
@kevinSmith , thanks for your input… I’m a newbie trying to learn JavaScript & React by doing project.
I’m trying to build a gradient color generator… User inputs color in two different text field to generate shades of gradient from the colors (I am using value.js).
So each color is generating arrays of different shades, just like what is up there.
So I think merging the arrays like this
let arr1 = ['a', 'b', 'c', 'd']
let arr2 = ['e', 'f', 'g', 'h']
let res = ['a e', 'b f', 'c g', 'd h']
Would make it more achievable hence the line of code:
I mean, further more, if they could have properties, what would it mean? You’re combining two objects with the same properties. Will the new object have two “alpha” properties, two “rgb” properties, etc.? Objects must have unique property names.
There’s nothing wrong with an array of objects. But that isn’t what you are showing there. What you have there is an object of arrays of objects. Or perhaps an “array like object” of arrays of objects.
I don’t understand how you ended up with three key/value pairs on the final. I don’t understand why some of the data was excluded.
Yes, something like this. If you don’t mind, can i drop the repository link so that you can the data yourself… Maybe I’m just not clear enough typing this out
That doesn’t really help me. What I need is an example of the input data and what you want the output data to be. That is, assuming that what I showed earlier isn’t sufficient.
Kindly have a look at the repo again… I have been able to render the gradient colors.
One question, when I clicked on generate button I couldn’t get any values, hence new colors can’t be generated… Even when handeColors() (this handle the merged array) is invoked in the handleSubmit function
Is it because I also invokedhandColors() in the useEffect. I did that to prevent infinite looks