FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript-Algorithms/single-linked-node.js at master · supsart/JavaScript-Algorithms · GitHub
supsart
/
JavaScript-Algorithms
Public
forked from
lightningtgc/JavaScript-Algorithms
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript-Algorithms
/
single-linked-node.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (37 loc) · 1.08 KB
Breadcrumbs
JavaScript-Algorithms
/
single-linked-node.js
Copy path
File metadata and controls
42 lines (37 loc) · 1.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var
SinglyLinkedList
=
function
(
)
{
}
SinglyLinkedList
.
prototype
=
{
addBottom
:
function
(
node
)
{
if
(
this
.
head
==
undefined
)
return
this
.
head
=
node
;
var
currentNode
=
this
.
head
;
while
(
currentNode
.
next
!==
undefined
)
{
currentNode
=
currentNode
.
next
;
}
currentNode
.
next
=
node
;
}
,
find
:
function
(
data
)
{
var
currentNode
=
this
.
head
;
while
(
currentNode
!==
undefined
)
{
if
(
currentNode
.
data
==
data
)
return
currentNode
;
currentNode
=
currentNode
.
next
;
}
}
,
addTop
:
function
(
node
)
{
if
(
this
.
head
==
undefined
)
return
this
.
head
=
node
;
node
.
next
=
this
.
head
;
this
.
head
=
node
;
}
,
remove
:
function
(
data
)
{
if
(
this
.
head
.
data
==
data
)
return
this
.
head
=
this
.
head
.
next
;
var
prevNode
=
this
.
head
;
var
currentNode
=
this
.
head
.
next
;
while
(
currentNode
!==
undefined
)
{
if
(
currentNode
.
data
==
data
)
{
prevNode
.
next
=
currentNode
.
next
;
return
currentNode
.
next
=
undefined
;
}
prevNode
=
currentNode
;
currentNode
=
currentNode
.
next
;
}
}
}
module
.
exports
=
SinglyLinkedList
;
Back
|
FazBrowse Home
|
New Git URL