how to take a random value from an object js

Solutions on MaxInterview for how to take a random value from an object js by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "how to take a random value from an object js"
Marie
17 Jan 2020
1var randomProperty = function (obj) {
2    var keys = Object.keys(obj);
3    return obj[keys[ keys.length * Math.random() << 0]];
4};
5