Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
myObj = {one: 1, two: 2, three: 3, four: {one: 1, two: 2, three: 3}}
// {one: 3, two: 6, three: 9}
    const mapObjRecursive = (obj) => {
      Object.keys(obj).forEach(key => {
        if (typeof obj[key] === 'object') obj[key] = mapObjRecursive(obj[key]);
        else obj[key] = obj[key] * 3;
      });
      return obj;
    };
console.log(mapObjRecursive(myObj));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers