I need to lookup a value in another array based on a key within the data joined to svg within d3.
The d3 joined dataset is
boundaries (which contains a key of
lad17cd for the local authority) and then I need to look up the population in
localAuthorities using the same key.
I’ve tried various ways (using find on local authorities and the  notation to refer to a key, but for that, I’m not sure how it would know which field is the key), but none seem to work.
Full code is at Carbon Calculator Map / Chris Woods / Observable, with the lookup code towards the bottom of
The currently uncommented line refers to a specific value of lad17cd and this works, but obviously I don’t want to hard code it.
Any pointers warmly welcomed.
const areaPaths = g.selectAll('path') .data(boundaries.features) .enter() .append('path') //.attr("fill", d => localAuthorities[d.properties.lad17cd].population > 100000 ? "#ffe26d" : "#c837ed") .attr("fill", localAuthorities.find(d => d.lad17cd === "E06000013").population < 100000 ? "#ffe26d" : "#c837ed") //.attr("fill", d => localAuthorities.find(la => la.lad17cd === d.properties.lad17cd).population < 100000 ? "#ffe26d" : "#c837ed")