JoeKarlsson/data-structures

View on GitHub
graph/tree.js

Summary

Maintainability
A
0 mins
Test Coverage
class Node {
  constructor( value ) {
    this.value = value;
    this.children = [];
  }

  getChildren() {
    return this.children;
  }

  addChild( child ) {
    this.children.push( child );
  }

  hasChildren() {
    return this.children.length > 0;
  }

  getValue() {
    return this.value;
  }

  toString() {
    return this.name;
  }
}

module.exports = Node;