Created
December 9, 2018 06:44
-
-
Save hyukkwonepic/d1dbe9e569d827a378a269cb682d6697 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
iterate() { | |
let node = this.head | |
while (node) { | |
console.log(node.data) | |
node = node.next | |
} | |
} | |
search(data) { | |
let idx = 0 | |
let node = this.head | |
while (node) { | |
if (node.data === data) return idx | |
node = node.next | |
idx += 1 | |
} | |
return -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment