Wherefore art thou: Original problem code changed so the solutions don't match

Hi there! New learner here. The original problem (https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou) changed slightly from the 3 published solutions (freeCodeCamp Challenge Guide: Wherefore art thou) which is a bit confusing for a new learner.

Each solution requires changing the first var (var arr = [];) and the last return (return arr;) but the instructions on the original problem do not want learners to touch the var arr or the return. The 3 solutions offered wouldn’t work if I placed them in between the lines of code as instructed.

1 Like

yeah i kinda had a hard time here, the new ones suggests us to push the answer to arr, it’s true that solutions are outdated but are still inspiring

It is not that the solutions are outdated. They solve the problem defined in the challenge instructions. The confusion may come into play based on where we placed the // Only change code below this line and the // Only change code above this line comments. We could modify the starting code to be:

function whatIsInAName(collection, source) {
  // Only change code below this line
  var arr = [];
  return arr;
  // Only change code above this line
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

OR

function whatIsInAName(collection, source) {
  // Only change code below this line

  // Only change code above this line
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

What do you think?

2 Likes

i think the first one would be pretty good

I agree with @danzel-py – I also like the first option.