/**
 * This exercise aims to test your understanding of breaking out of a loop while iterating over each character of a string.
 *
 * Given a string and a target character, your task is to write a function that finds the index of the first occurrence of the target character in the string.
 *
 * @param string A string containing characters (no empty strings)
 * @param target A single character to find in the string
 * @return The index of the first occurrence of the target character in the string (0-indexed)
 *         If the target character is not found in the string, return -1
 *
 * Example:
 * findCharacter("hello world", 'o') => 4
 * findCharacter("hello world", 'w') => 6
 * findCharacter("hello world", 'z') => -1
 */
fun findCharacter(string: String, target: Char): Int {

    // Iterate over each character in the string
    for ((index, char) in string.withIndex()) {
        // Check if the current character matches the target
        if (char == target) {
            return index
        }
    }
    // If the target character is not found, return -1
    return -1
}
/**
 * This exercise aims to test your understanding of breaking out of a loop while iterating over each character of a string.
 *
 * Given a string and a target character, your task is to write a function that finds the index of the first occurrence of the target character in the string.
 *
 * @param string A string containing characters (no empty strings)
 * @param target A single character to find in the string
 * @return The index of the first occurrence of the target character in the string (0-indexed)
 *         If the target character is not found in the string, return -1
 *
 * Example:
 * findCharacter("hello world", 'o') => 4
 * findCharacter("hello world", 'w') => 6
 * findCharacter("hello world", 'z') => -1
 */
fun findCharacter(string: String, target: Char): Int {
/**
 * This exercise aims to test your understanding of breaking out of a loop while iterating over each character of a string.
 *
 * Given a string and a target character, your task is to write a function that finds the index of the first occurrence of the target character in the string.
 *
 * @param string A string containing characters (no empty strings)
 * @param target A single character to find in the string
 * @return The index of the first occurrence of the target character in the string (0-indexed)
 *         If the target character is not found in the string, return -1
 *
 * Example:
 * findCharacter("hello world", 'o') => 4
 * findCharacter("hello world", 'w') => 6
 * findCharacter("hello world", 'z') => -1
 */
fun findCharacter(string: String, target: Char): Int {

    // Iterate over each character in the string
    for ((index, char) in string.withIndex()) {
        // Check if the current character matches the target
        if (char == target) {
            return index
        }
    }
    // If the target character is not found, return -1
    return -1
}