/**
 * Given two strings, find the intersection (common characters) between the two strings. The result should be a string
 * containing only the characters that occur in both strings, in the order they appear in the first string. Ignore
 * duplicate characters.
 *
 * @param string1 The first string (must be a non-empty string)
 * @param string2 The second string (must be a non-empty string)
 * @return A string containing the characters that are common to both input strings, in the order they appear in string1.
 *
 * Example:
 * getCommonCharacters("engineering", "intersection") -> "ener"
 *
 * Hint:
 * Use string iteration to iterate through the characters in string1.
 */
fun getCommonCharacters(string1: String, string2: String): String {

    var commonCharacters = ""
    for (char in string1) {  // For each character in string1
        if (char in string2 && char !in commonCharacters) {  // If character is also in string2 and not already added
            commonCharacters += char  // Add character to the result string
        }
    }
    return commonCharacters
}
/**
 * Given two strings, find the intersection (common characters) between the two strings. The result should be a string
 * containing only the characters that occur in both strings, in the order they appear in the first string. Ignore
 * duplicate characters.
 *
 * @param string1 The first string (must be a non-empty string)
 * @param string2 The second string (must be a non-empty string)
 * @return A string containing the characters that are common to both input strings, in the order they appear in string1.
 *
 * Example:
 * getCommonCharacters("engineering", "intersection") -> "ener"
 *
 * Hint:
 * Use string iteration to iterate through the characters in string1.
 */
fun getCommonCharacters(string1: String, string2: String): String {
/**
 * Given two strings, find the intersection (common characters) between the two strings. The result should be a string
 * containing only the characters that occur in both strings, in the order they appear in the first string. Ignore
 * duplicate characters.
 *
 * @param string1 The first string (must be a non-empty string)
 * @param string2 The second string (must be a non-empty string)
 * @return A string containing the characters that are common to both input strings, in the order they appear in string1.
 *
 * Example:
 * getCommonCharacters("engineering", "intersection") -> "ener"
 *
 * Hint:
 * Use string iteration to iterate through the characters in string1.
 */
fun getCommonCharacters(string1: String, string2: String): String {

    var commonCharacters = ""
    for (char in string1) {  // For each character in string1
        if (char in string2 && char !in commonCharacters) {  // If character is also in string2 and not already added
            commonCharacters += char  // Add character to the result string
        }
    }
    return commonCharacters
}