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

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