Help - Wherefore art thou Algorithm

I’ve tried many of things to make this work. I’m trying to extract the values from the properties that is source. If I do the following, I can only extract the first:

let b = Object.values(source);

I’ve tried using loops and some methods. Can anyone help me out with a hint?

Here’s the code that I’ve written:

let b = Object.values(source);
  let c = '';
  c = b.shift();
  console.log(c); // 'Capulet'
  for(let i = 0; i < collection.length; i++) {
    for(let key in source) {
      console.log(key);
      if(collection[i].hasOwnProperty(key) && collection[i][key]  === c ){
        arr.push(collection[i]);
      } 
    };// for key
  }; // for loop

Thanks.

Nope

const arr = [];
  // Only change code below this line
let b = Object.keys(source);
for(let x = 0; x < b.length; x++) {
  console.log(source[b[x]])
for(let i = 0; i < collection.length; i++) {
    for(let key in source) {
      console.log(key);
      if(collection[i].hasOwnProperty(key) && collection[i][key] === (source[b[x]])){
        arr.push(collection[i]);
      } 
    };// for key
  }; // for loop

}

Hey, can you show us what kind of data your expecting for source? I understand it’s an object, but it would help to visualize things.

It appears like you are trying to code a solution before understanding the algorithm for the solution. See if you can describe the algorithm for the challenge and then we can help guide you to code it.

Hey, I managed to get it working. You’re on the right path with trying to extract the keys. Try to make a written pseudocode for each step. It helped out a lot.

A function looks through collection for its keys
For let key in collection
IF key in collection is the same as in source and key in collection and source have the same value
THEN push object into arr