/**
 * This exercise requires you to write a function that takes in a string (text) and a letter.
 * The function should find all the indices at which the letter appears in the string using a while loop.
 * Your task is to complete the function by writing the code inside the while loop.
 *
 * @param text A string in which to search for the letter.
 * @param letter The letter to search for.
 * @return A list of indices at which the letter appears in the string.
 *
 * Example:
 * findMatchingLetters("journalist", "i") // [4, 7]
 */
fun findMatchingLetters(text: String, letter: Char): List<Int> {

    val indices = mutableListOf<Int>()
    var index = 0

    while (index < text.length) {
        // Write your code here:
        if (text[index] == letter) {
            indices.add(index)
        }
        index++
    }

    return indices
}
/**
 * This exercise requires you to write a function that takes in a string (text) and a letter.
 * The function should find all the indices at which the letter appears in the string using a while loop.
 * Your task is to complete the function by writing the code inside the while loop.
 *
 * @param text A string in which to search for the letter.
 * @param letter The letter to search for.
 * @return A list of indices at which the letter appears in the string.
 *
 * Example:
 * findMatchingLetters("journalist", "i") // [4, 7]
 */
fun findMatchingLetters(text: String, letter: Char): List<Int> {
/**
 * This exercise requires you to write a function that takes in a string (text) and a letter.
 * The function should find all the indices at which the letter appears in the string using a while loop.
 * Your task is to complete the function by writing the code inside the while loop.
 *
 * @param text A string in which to search for the letter.
 * @param letter The letter to search for.
 * @return A list of indices at which the letter appears in the string.
 *
 * Example:
 * findMatchingLetters("journalist", "i") // [4, 7]
 */
fun findMatchingLetters(text: String, letter: Char): List<Int> {

    val indices = mutableListOf<Int>()
    var index = 0

    while (index < text.length) {
        // Write your code here:
        if (text[index] == letter) {
            indices.add(index)
        }
        index++
    }

    return indices
}