/**
 * This function takes a list of news headlines, a category, a search term, and a limit as arguments.
 * It returns the specified number of top headlines that match the given criteria.
 */
fun getTopHeadlines(newsList: List<String>? = null, category: String? = null, searchTerm: String? = null, limit: Int? = null): List<String> {

    var mutableNewsList = newsList ?: emptyList()
    val mutableCategory = category ?: ""
    val mutableSearchTerm = searchTerm ?: ""
    val mutableLimit = limit ?: 5
    val filteredList = mutableListOf<String>()

    for (headline in mutableNewsList) {
        if (mutableCategory.toLowerCase() in headline.toLowerCase() && mutableSearchTerm.toLowerCase() in headline.toLowerCase()) {
            filteredList.add(headline)
        }
    }

    return filteredList.take(mutableLimit)
}
/**
 * This function takes a list of news headlines, a category, a search term, and a limit as arguments.
 * It returns the specified number of top headlines that match the given criteria.
 */
fun getTopHeadlines(newsList: List<String>? = null, category: String? = null, searchTerm: String? = null, limit: Int? = null): List<String> {
/**
 * This function takes a list of news headlines, a category, a search term, and a limit as arguments.
 * It returns the specified number of top headlines that match the given criteria.
 */
fun getTopHeadlines(newsList: List<String>? = null, category: String? = null, searchTerm: String? = null, limit: Int? = null): List<String> {

    var mutableNewsList = newsList ?: emptyList()
    val mutableCategory = category ?: ""
    val mutableSearchTerm = searchTerm ?: ""
    val mutableLimit = limit ?: 5
    val filteredList = mutableListOf<String>()

    for (headline in mutableNewsList) {
        if (mutableCategory.toLowerCase() in headline.toLowerCase() && mutableSearchTerm.toLowerCase() in headline.toLowerCase()) {
            filteredList.add(headline)
        }
    }

    return filteredList.take(mutableLimit)
}