7 kyu

Search JSON for any key value pair

Description:

You have a friend who works for a well known animation studio. He has heard you talk about your mad programming skills and ask for your help in writing a function that can search some JSON records and return matching character details.

He needs to be able to search for objects in the collection by any of the objects keys and return an array of all the matches.

The basic structure of the JSON object is shown below:

characters = {"characters": [
    {"name":"Bill Cipher", "age":"Unknown", "speciality":"warp reality"},
    // ......
]};

The JSON object is preloaded and can be accessed using the variable characters.

Your function will also need to accommodate the following:

  • Passed value does not match any keys: in this instance return an empty array.
  • Passed key does not exist: in this instance return an empty array.
  • Passed val should not be case sensitive.
JSON
Fundamentals
Arrays

More By Author:

Check out these other kata created by incidental

Stats:

CreatedAug 20, 2015
PublishedAug 20, 2015
Warriors Trained2116
Total Skips91
Total Code Submissions5440
Total Times Completed910
JavaScript Completions910
Total Stars40
% of votes with a positive feedback rating82% of 148
Total "Very Satisfied" Votes107
Total "Somewhat Satisfied" Votes29
Total "Not Satisfied" Votes12
Ad
Contributors
  • incidental Avatar
  • ooflorent Avatar
  • GiacomoSorbi Avatar
  • Voile Avatar
  • dfhwze Avatar
  • LosBlobbos Avatar
Ad