I was wondering how can I match data from 2 arrays so that I can use the data to generate diagrams using d3.js
Current I have 2 arrays:
wordsArray = {"THE","MAIN","PURPOSE","OF","PHOTOSYNTHESIS","IS","TO","MAKE", "FOOD","FOR","PLANT","IT","PRODUCE","SUGAR","MANUFACTURE"}; computationArray = {6,1,2,2,1,3,3,1,3,4,4,2,1,2,1};
Array words contain all the different words, and computationArray indicates the number of times each word appears.
I would like to know if there is any shortcut so that it looks like this:
var data = [{"words":"THE", "count": "6"}, {"words":"MAIN", "count": "1"}, {"words":"PURPOSE", "count": "2"}, {"words":"OF", "count": "2"}.... ];
Thanks!