0

I have tried this but if i do nested loop I cannot able to get the output for that particular nested one

Error output image

const obj = {
  "foo": 'bar',
  "baz": 42,
  "name": "uday",
  "age": 24,
  "studies": {
    "college": "Jeppiaar"
  }
};
Object.entries(obj).forEach(([key, value]) => console.log(`${key}: ${value}`));

If i add many nested loops inside the object variable it should display the output properly.can anyone help me to solve this question please? Thanks in advance.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • why would you imagine this would recursively loop on it's own? see: [(Recursion) How to get all key/value pairs from an Object with nested objects and arrays](https://stackoverflow.com/questions/63586555/recursion-how-to-get-all-key-value-pairs-from-an-object-with-nested-objects-an) or [Recursively accessing key/value pairs of object within objects & combining them together into a flat array](https://stackoverflow.com/questions/59274940/recursively-accessing-key-value-pairs-of-object-within-objects-combining-them) – pilchard May 12 '22 at 14:49
  • `const obj` means you're dealing with a javascript object, not JSON. - Also the question does not have any nested-loops – evolutionxbox May 12 '22 at 14:49
  • Also, you're not receiving an error, the script just finishes. – pilchard May 12 '22 at 14:54

0 Answers0