For instance, if I have two arrays that look like this:
var array1 = ['a','b'];
var array2 = [1, 1];
The output array should be:
var newArray = ['a:1', 'b:1']
You could use map
like this:
var array1 = ['a','b'], array2 = [1, 1];
var newArray = array1.map((e, i) => `${e}:${array2[i]}`);
console.log(newArray);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With