I am trying to filter through this javascript object using underscore.js, but I don’t know why it’s not working, its meant to find any question value that has “how” in it.
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 match = _.filter(questions),function(words){ return words === "how"});
alert(match); // its mean to print out -> how old are you?
the full code is here(underscore.js already included): http://jsfiddle.net/7cFbk/
.filter(questions). The last)shouldn’t be there.{question: "..."}, not a string.console.loginstead.So: http://jsfiddle.net/7cFbk/45/