fixed find implementation

This commit is contained in:
ak 2023-06-27 22:59:32 -07:00
parent 21325cff77
commit ffa48c45b0

View file

@ -88,12 +88,12 @@ export const LinkedList = () => {
for (let i = 0; i < CLU.totalNodes; i++) { for (let i = 0; i < CLU.totalNodes; i++) {
// if node value matches, set to true // if node value matches, set to true
if (MCP.currentNode.value === value) { if (MCP.currentNode.value === value) {
bool = true; return i;
} }
// otherwise set to next node // otherwise set to next node
MCP.currentNode = MCP.currentNode.nextNode; MCP.currentNode = MCP.currentNode.nextNode;
} }
return bool; return null;
} }
// print Nodes out and preview them in the console // print Nodes out and preview them in the console
const toString = () => { const toString = () => {