 <p><strong>Function to get random integers where min, max are inclusive</strong></p> <pre><code>function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } </code></pre> <p><strong>Function to find Random Value from passed variable <code>plot</code></strong></p> <pre><code>function getRandomValue(plot) { var rN1 = getRandomInt(0,plot.length-1); var areaArray= plot[rN1].area.split(","); var rN2 = getRandomInt(0,areaArray.length-1); return areaArray[rN2]; } </code></pre> <p><strong>And use it like</strong></p> <pre><code>plot = [ { postcode: "MK1", area: "Denbigh, Mount Farm", }, { postcode: "MK2", area: "Brickfields, Central Bletchley, Fenny Stratford, Water Eaton" }, { postcode: "MK3", area: "Church Green, Far Bletchley, Old Bletchley, West Bletchley", }, { postcode: "MK4", area: "Emerson Valley, Furzton, Kingsmead, Shenley Brook End, Snelshall West, Tattenhoe, Tattenhoe Park, Westcroft, Whaddon, Woodhill", }, { postcode: "MK5", area: "Crownhill, Elfield Park, Grange Farm, Oakhill, Knowlhill, Loughton, Medbourne, Shenley Brook End, Shenley Church End, Shenley Lodge, Shenley Wood", } ] console.log(getRandomValue(plot)) </code></pre>