(id, children, depth)
| 15 | |
| 16 | tree = (() => { |
| 17 | function createSubtree(id, children, depth) { |
| 18 | const el = doc.createElement('div'); |
| 19 | el.id = id; |
| 20 | el.textContent = id; |
| 21 | if (depth > 1) { |
| 22 | for (let i = 0; i < children; i++) { |
| 23 | const child = createSubtree(`${id}-${i + 1}`, children, depth - 1); |
| 24 | el.appendChild(child); |
| 25 | } |
| 26 | } |
| 27 | return el; |
| 28 | } |
| 29 | return createSubtree('T', 4, 4); |
| 30 | })(); |
| 31 |