I want to know if I executed this challenge properly

Hello everyone, I wanted to ask you that if I’m doing this ‘Wherefore art thou’ JavaScript challenge correctly or properly and if not then where should I focus more on when it comes to learning JavaScript and how can I improve because I’ve been figuring out how to do this for days now and when I finally did I felt like I was missing something even though I completed the challenge. I didn’t look at the solution but I was searching and reading on MDN obviously because I didn’t know the ‘Object.keys()’ methods or anything. So it took me a lot of time to get through this challenge. I feel like I don’t know much about certain concepts or topics when it comes to learning JavaScript. I’m looking for some guidance, so if anyone can help me understand it would be much appreciated. Anyways here’s my solution :

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

  let finalArr;
  for(let i = 0; i < collection.length; i++){
    if(collection[i].hasOwnProperty(...Object.keys(source))){
        for(let prop in source){
          finalArr = collection.filter((obj) => {
            if(obj.hasOwnProperty(...Object.keys(source)) && obj[prop] === source[prop]){
              return true;
            }else{
              return false;
            }
          });
        [arr] = [finalArr];
      }

        for(let property in source){
            if(collection[i][property] !== source[property]){
              arr.splice(0, );
            }
          }
        
    }
  }

  // Only change code above this line
  return arr;
}

console.log(whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }, { "bat":2 }], { "apple": 1, "bat": 2 }));

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.