/**
 * This exercise is designed for geologists. You are given two strings, word1 and word2, each representing the names of geological formations.
 * Your task is to write a function that finds and returns a string containing the common letters between the two words. The order of the letters in the resulting string should match the order they appear in word1.
 * In order to solve this exercise, you need to use a while loop to iterate through each character in word1 and check if it also exists in word2. If a common letter is found, it should be added to a new string variable called commonLetters. Finally, you should return the commonLetters string.
 */
fun findCommonLetters(word1: String, word2: String): String {

    var commonLetters = ""
    var i = 0
    while (i < word1.length) {
        var j = 0
        while (j < word2.length) {
            if (word1[i] == word2[j]) {
                commonLetters += word1[i]
                break
            }
            j++
        }
        i++
    }
    return commonLetters
}
/**
 * This exercise is designed for geologists. You are given two strings, word1 and word2, each representing the names of geological formations.
 * Your task is to write a function that finds and returns a string containing the common letters between the two words. The order of the letters in the resulting string should match the order they appear in word1.
 * In order to solve this exercise, you need to use a while loop to iterate through each character in word1 and check if it also exists in word2. If a common letter is found, it should be added to a new string variable called commonLetters. Finally, you should return the commonLetters string.
 */
fun findCommonLetters(word1: String, word2: String): String {
/**
 * This exercise is designed for geologists. You are given two strings, word1 and word2, each representing the names of geological formations.
 * Your task is to write a function that finds and returns a string containing the common letters between the two words. The order of the letters in the resulting string should match the order they appear in word1.
 * In order to solve this exercise, you need to use a while loop to iterate through each character in word1 and check if it also exists in word2. If a common letter is found, it should be added to a new string variable called commonLetters. Finally, you should return the commonLetters string.
 */
fun findCommonLetters(word1: String, word2: String): String {

    var commonLetters = ""
    var i = 0
    while (i < word1.length) {
        var j = 0
        while (j < word2.length) {
            if (word1[i] == word2[j]) {
                commonLetters += word1[i]
                break
            }
            j++
        }
        i++
    }
    return commonLetters
}