/**
 * Given a list of names and a separator, returns a string that consists of all the names joined by the separator.
 *
 * @param names List<String> A list of strings representing names.
 * @param separator String A string used as a separator for joining the names.
 * @return String A string containing all the names joined by the separator.
 *
 * Example:
 * joinNames(listOf("John", "Doe", "Smith"), "-") returns "John-Doe-Smith"
 */
fun joinNames(names: List<String>, separator: String): String {

    if (names.isEmpty()) {
        return ""
    }

    // Start with the first name in the list
    var result = names[0]

    // Iterate over the remaining names in the list
    for (i in 1 until names.size) {
        result += "$separator${names[i]}"
    }

    return result
}
/**
 * Given a list of names and a separator, returns a string that consists of all the names joined by the separator.
 *
 * @param names List<String> A list of strings representing names.
 * @param separator String A string used as a separator for joining the names.
 * @return String A string containing all the names joined by the separator.
 *
 * Example:
 * joinNames(listOf("John", "Doe", "Smith"), "-") returns "John-Doe-Smith"
 */
fun joinNames(names: List<String>, separator: String): String {
/**
 * Given a list of names and a separator, returns a string that consists of all the names joined by the separator.
 *
 * @param names List<String> A list of strings representing names.
 * @param separator String A string used as a separator for joining the names.
 * @return String A string containing all the names joined by the separator.
 *
 * Example:
 * joinNames(listOf("John", "Doe", "Smith"), "-") returns "John-Doe-Smith"
 */
fun joinNames(names: List<String>, separator: String): String {

    if (names.isEmpty()) {
        return ""
    }

    // Start with the first name in the list
    var result = names[0]

    // Iterate over the remaining names in the list
    for (i in 1 until names.size) {
        result += "$separator${names[i]}"
    }

    return result
}