Looking to connect an array of three-letter codes in JavaScript with corresponding values stored in a JSON file. Let's illustrate with an example:
{"Roles" : [
{"code": "cmm", "fullname": "commentator"},
{"code": "cmp", "fullname": "composer"},
{"code": "cnd", "fullname": "conductor"},
{"code": "cng", "fullname": "cinematographer"},
{"code": "cns", "fullname": "censor"},
{"code": "com", "fullname": "compiler"}
]}
var arr = ["cmm", "com", "cng"];
var mappedArray = arr.map( ??? );
//mappedArray now contains: ["commentator", "composer", "cinematographer"]
Struggling to find an efficient solution for this problem. Any suggestions?