Write a function named searchMessages
that receives 2 parameters:
messages
, each with 2 properties:body
- the text inside the messagesentAt
- a Date representing when the message was sentsearchTerm
The function should find all messages that match the searchTerm
. A message matches it if:
body
body
Then return all those messages in descending order based on:
searchTerm
they matchsentAt
property (newest first)NOTE: the search is not case sensitive
messages
=searchTerm
=