const data = {
"dev": [
{ "username": "test1", "password": "qwerty" },
{ "username": "test2", "password": "abcdef" },
{ "username": "test3", "password": "abcdef" },
{ "username": "test4", "password": "abcdef" }
],
"staging": [
{ "username": "test1", "password": "qwerty" },
{ "username": "test2", "password": "abcdef" }
],
};
console.log(JSON.stringify(data.dev[Math.floor(Math.random() * 4)]));
OUTPUT: {"username":"test2","password":"abcdef"}
How to extract test2 and abcdef from the output I am getting?
Aucun commentaire:
Enregistrer un commentaire