How do I select random value (property and its key) from the object and append each one to specific div?
<
If you put the object's keys in an array then you can easily select one at random, maybe a little something like this:
var student = { name : "John Doe", age : "28", gender : "Male" };
var keys = Object.keys(student);
var randomKey = keys[Math.floor(Math.random()*keys.length)];
var randomValue = student[randomKey];
document.getElementById("propertydiv").innerHTML = randomKey;
document.getElementById("valuediv").innerHTML = randomValue;
(Run the snippet above several times to see the random behaviour.)
Further reading: