Created
April 18, 2017 01:04
-
-
Save pporche87/8ca9cc085a66896c1b8a5771da64d908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Node { | |
constructor(data){ | |
this.data = data | |
this.next = undefined | |
} | |
getData() { | |
// returns the data ("apple") of the node | |
return this.data | |
} | |
setNext(nodeB){ | |
// changes the reference to the next node and returns the original node | |
this.next = nodeB | |
return this | |
} | |
getNext(nextNode){ | |
// returns the next node, or null if no next node | |
if (nextNode === undefined) { | |
return null | |
} else { | |
return this.next | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment