Here is the working version:
var questions = [ {question: "what is your name"}, {question: "How old are you"}, {question: "whats is your mothers name"}, {question: "where do work/or study"}, ]; var hasHow = _.filter(questions, function(q){return q.question.match(/how/i)}); console.log(hasHow);
fixed:
- Parens were not placed correctly.
- Use
console.log instead of warning. - You should probably use a regular expression to search for "how" when repeating each question.
_filter over the array. Your array contains objects, and each object contains a question. The function you pass to _filter should check each object in the same way.
David weldon
source share