Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Javascript combining arrays using first array as key

$
0
0

I have the following arrays:

var a = ["F", "M"];
var b = ["female", "male"];
var c = ["fa-female", "fa-male"];

and I am able to assign b to a using for loop with:

ans[a[i]] = values[i]; // { M: "male", F: "female" }

how would I go about adding the third array and assign it to a as well?

{ M: {"male", "fa-male"}, F: {"female", "fa-female"} }

or something similar?

EDIT: Result could either be an array or an object.


Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>