Answers for "javascript pick random attribute from object"

0

javascript pick random attribute from object

const animals = {
  'cat': 'meow',
  'dog': 'woof',
  'cow': 'moo',
  'sheep': 'baaah',
  'bird': 'tweet'
};

const keys = Object.keys(animals)
const prop = keys[Math.floor(Math.random() * keys.length)]
console.log(prop);
Posted by: Guest on September-04-2021

Code answers related to "javascript pick random attribute from object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language