JSFiddle - React, Tailwind, and code Playground
JavaScript
var rr ={
"Физика": [
{
"01.02.20111": [
{
"ppe1цццц": ["комната 5311", "комната 4565422"],
"ppe22": ["комната 123", "комната 2687"]
}
]
},
{
"01.02.2021": [
{
"ppe1ssssss": ["комната 1", "комната 2"],
"ppe2": ["комната 1", "комната 2"]
}
]
}
]
};
const findByKey = (object, key) => {
for (let p in object) {
if (p === key) {
return object[p]
} else if (typeof object[p] === 'object') {
let result = findByKey(object[p], key);
if (result !== null) {
return result;
}
}
return null;
}
}
console.log(findByKey(rr, 'ppe2'))