My goal is to retrieve the object that contains a value matching the searched text. Currently, I achieve this using the return match function. However, I am facing difficulties in testing for numbers within the array. The current implementation only works if I input the type or the name.
For instance, if I input '2', the expected output should be [{"type":"ABe 8/12", "name":"ZTZ","numbers":["1", "2", "3", "4", "7"]}]
The JSON data:
[
{"type":"ABe 8/12", "name":"ZTZ","numbers":["1", "2", "3", "4", "7"]},
{"type":"ABe 4/16", "name":"STZ","numbers":["5", "6", "8", "9", "12"]},
{"type":"ABe 4/16", "name":"RTZ", "numbers":["10", "11", "13", "14", "15"]},
{"type":"Test", "name":"RTZ", "numbers":["16", "17", "18", "19", "20"]}
]
The provided Javascript code fetches the data from the JSON file and filters it based on the search text entered by the user. It then logs the matches to the console.
If anyone has an alternative method to achieve this other than using the return match function, please let me know.