/**
 * This exercise requires concatenating two strings and modifying elements in a list.
 *
 * Given a list of firefighter names, the function 'concatenateAndModify' takes a new name and a change index as inputs.
 * It concatenates the new name with the firefighter name at position changeIndex in the list, and modifies the list accordingly.
 *
 * @param firefighterList A list of firefighter names.
 * @param newName The new name that needs to be concatenated.
 * @param changeIndex The index of the firefighter name that should be modified.
 * @return The modified list of firefighter names after concatenating the new name.
 *
 * Example:
 * firefighterList = listOf("John", "Michael", "David")
 * concatenateAndModify(firefighterList, " - Brave Firefighter", 1)
 * Output: ["John", "Michael - Brave Firefighter", "David"]
 */
fun concatenateAndModify(firefighterList: MutableList<String>, newName: String, changeIndex: Int): List<String> {

    if (changeIndex >= 0) {
        firefighterList[changeIndex] += newName
        return firefighterList
    } else {
        throw IllegalArgumentException("Invalid index value. Index should be greater than or equal to 0")
    }
}
/**
 * This exercise requires concatenating two strings and modifying elements in a list.
 *
 * Given a list of firefighter names, the function 'concatenateAndModify' takes a new name and a change index as inputs.
 * It concatenates the new name with the firefighter name at position changeIndex in the list, and modifies the list accordingly.
 *
 * @param firefighterList A list of firefighter names.
 * @param newName The new name that needs to be concatenated.
 * @param changeIndex The index of the firefighter name that should be modified.
 * @return The modified list of firefighter names after concatenating the new name.
 *
 * Example:
 * firefighterList = listOf("John", "Michael", "David")
 * concatenateAndModify(firefighterList, " - Brave Firefighter", 1)
 * Output: ["John", "Michael - Brave Firefighter", "David"]
 */
fun concatenateAndModify(firefighterList: MutableList<String>, newName: String, changeIndex: Int): List<String> {
/**
 * This exercise requires concatenating two strings and modifying elements in a list.
 *
 * Given a list of firefighter names, the function 'concatenateAndModify' takes a new name and a change index as inputs.
 * It concatenates the new name with the firefighter name at position changeIndex in the list, and modifies the list accordingly.
 *
 * @param firefighterList A list of firefighter names.
 * @param newName The new name that needs to be concatenated.
 * @param changeIndex The index of the firefighter name that should be modified.
 * @return The modified list of firefighter names after concatenating the new name.
 *
 * Example:
 * firefighterList = listOf("John", "Michael", "David")
 * concatenateAndModify(firefighterList, " - Brave Firefighter", 1)
 * Output: ["John", "Michael - Brave Firefighter", "David"]
 */
fun concatenateAndModify(firefighterList: MutableList<String>, newName: String, changeIndex: Int): List<String> {

    if (changeIndex >= 0) {
        firefighterList[changeIndex] += newName
        return firefighterList
    } else {
        throw IllegalArgumentException("Invalid index value. Index should be greater than or equal to 0")
    }
}