Skip to content

Instantly share code, notes, and snippets.

@pporche87
Created April 18, 2017 01:04
Show Gist options
  • Save pporche87/8ca9cc085a66896c1b8a5771da64d908 to your computer and use it in GitHub Desktop.
Save pporche87/8ca9cc085a66896c1b8a5771da64d908 to your computer and use it in GitHub Desktop.
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