GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — algorithms/tree.js at master · bettychow/algorithms Expand file tree/ Copy pathtree.jsMore file actions 28 lines (23 loc) · 461 Bytes / Copy pathtree.jsFile metadata and controls28 lines (23 loc) · 461 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 class Node { constructor(v, children) { this.value = v; this.children = children; } } const sumNode = (node) => { let sum = 0; if (node) { sum += node.value} let remainder = node.children; while(remainder[0]) { sum += remainder[0].value; if (remainder[0].children !== undefined) { remainder = remainder.concat(remainder[0].children) } remainder.splice(0,1); } return sum; }; module.exports = { node: Node, sumNode: sumNode }; |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |