Git Product home page Git Product logo

bfs-lab's Issues

Solution does not accept array in different order

Solution to test #1 "should return an array of adjacent nodes" accepts
[{name: '23rd&6th', distance: null, predecessor: null}, {name: '28th&Bwy', distance: null, predecessor: null}]
but not
[{name: '28th&Bwy', distance: null, predecessor: null}, {name: '23rd&6th', distance: null, predecessor: null}]

The order of the array received should not matter.

Here is my whole findAdjacent function that works:
`const findAdjacent = (node, verticies, edges) => {
let adjacent = []

edges.forEach(pair => {
if (pair[0] === node) {
adjacent.push(pair[1])
}
if (pair[1] === node) {
adjacent.push(pair[0])
}
})
let nodes = []

while (adjacent.length > 0) {
const name = adjacent.pop()

verticies.forEach(vert => {
  if (name === vert.name && vert.distance === null) {
    nodes.push(vert)
  }
})

}

return nodes.reverse()
}`

and my failing one:
`const findAdjacent = (node, verticies, edges) => {
let adjacent = []

edges.forEach(pair => {
if (pair[0] === node) {
adjacent.push(pair[1])
}
if (pair[1] === node) {
adjacent.push(pair[0])
}
})

let nodes = []

while (adjacent.length > 0) {
const name = adjacent.pop()

verticies.forEach(vert => {
  if (name === vert.name && vert.distance === null) {
    nodes.push(vert)
  }
})

}

return nodes
}`

Please note the only difference being .reverse() on the last line.

test has irrelevant comments

lines 41-43 have comments as follow:
// but these nodes are not in the node list? // 23rd&Broadway // 33rd&Lex

23rd&Bwy actually does exist in the vertices array, on line 22.
33rd&Lex does not exist but is not relevant to the previous question.

These comments just add confusion and don't add any clarifying or relevant information.

predecessors

I found the 'predecessor' properties to be confusing. There wasn't really any explanation of what they are, and they don't appear to have any purpose in the code.

The predecessor seems to be a pointer back the to 'parent' node, and at some iteration of the curriculum it probably made sense, but currently it isn't needed.

I'd be happy to rewrite the lab to remove it if that would be helpful.

findAdjacent function misnamed

the describe line of the #findAdjacent function names it 'findAdjacentNodes' but then the expect line just calls it 'findAdjacent,' so the test fails if you name your function #findAdjacentNodes instead of #findAdjacent. not a huge thing, but causes some initial confusion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.