Last active
April 25, 2020 05:13
-
-
Save adslaton/69722ed82b60fd474a0d24ba9999f6f7 to your computer and use it in GitHub Desktop.
quick-find-eager
This file contains hidden or 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
const connections = [ | |
{ | |
id: 0, | |
name: 0 | |
}, | |
{ | |
id: 1, | |
name: 1 | |
}, | |
{ | |
id: 1, | |
name: 2 | |
}, | |
{ | |
id: 8, | |
name: 3 | |
}, | |
{ | |
id: 8, | |
name: 4 | |
}, | |
{ | |
id: 0, | |
name: 5 | |
}, | |
{ | |
id: 0, | |
name: 6 | |
}, | |
{ | |
id: 1, | |
name: 7 | |
}, | |
{ | |
id: 8, | |
name: 8 | |
}, | |
{ | |
id: 8, | |
name: 9 | |
} | |
]; | |
const union = (p, q) => { | |
connections.map((element, i) => { | |
if (element.name === p) { | |
element.id = q; | |
} | |
}) | |
}; | |
const connected = (p, q) => { | |
let connection = false; | |
connections.map((element, i) => { | |
if (element.name === p && element.id === q) { | |
connection = true; | |
} | |
}) | |
return connection; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment