Intermediate Algorithm Scripting - Wherefore art thou

Hello

I am trying to solve this challenge but there is a syntax error and I couldn’t figure it

can anybody tell me how can I fix it

I am tring to solve this exercise but there is an error and I cannot figure out what is it

function whatIsInAName(collection, source) {
  let sourceArr = Object.keys(source);
  let newArr = [];

  collection.filter(item => {
    for (let prop in item) {
      sourceArr.includes(prop);
    }

  }
    for (let i = 0; i < collection.length; i++) {


    for (let prop in collection[i]) {
      if (prop == Object.keys(source)[0] && collection[i][prop] == source[Object.keys(source)[0]]) {

        newArr.push(collection[i])

      }
    }
  }
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36

Challenge: Intermediate Algorithm Scripting - Wherefore art thou

Link to the challenge:

You haven’t closed the parentheses on your filter method, which is the reason for your syntax error.
Other than that, your function isn’t really doing what is intended, so you’ll need to break it down and figure out how to get the result you need.

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