/**
 * This exercise focuses on identity comparison and using the range function with lists.
 *
 * Your task is to compare two lists and return a new list containing the common elements between them.
 * Remember to use identity comparison (is) while comparing the elements.
 *
 * Example:
 * -----------
 * Input:
 * list1 = ['apple', 'banana', 'carrot', 'date', 'egg']
 * list2 = ['carrot', 'date', 'egg', 'fig', 'grape']
 *
 * Output:
 * ['carrot', 'date', 'egg']
 * -----------
 */
fun compareLists(list1: List<String>, list2: List<String>): List<String> {

    val commonElements = mutableListOf<String>()

    for (element in list1) {
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * This exercise focuses on identity comparison and using the range function with lists.
 *
 * Your task is to compare two lists and return a new list containing the common elements between them.
 * Remember to use identity comparison (is) while comparing the elements.
 *
 * Example:
 * -----------
 * Input:
 * list1 = ['apple', 'banana', 'carrot', 'date', 'egg']
 * list2 = ['carrot', 'date', 'egg', 'fig', 'grape']
 *
 * Output:
 * ['carrot', 'date', 'egg']
 * -----------
 */
fun compareLists(list1: List<String>, list2: List<String>): List<String> {
/**
 * This exercise focuses on identity comparison and using the range function with lists.
 *
 * Your task is to compare two lists and return a new list containing the common elements between them.
 * Remember to use identity comparison (is) while comparing the elements.
 *
 * Example:
 * -----------
 * Input:
 * list1 = ['apple', 'banana', 'carrot', 'date', 'egg']
 * list2 = ['carrot', 'date', 'egg', 'fig', 'grape']
 *
 * Output:
 * ['carrot', 'date', 'egg']
 * -----------
 */
fun compareLists(list1: List<String>, list2: List<String>): List<String> {

    val commonElements = mutableListOf<String>()

    for (element in list1) {
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)
        }
    }

    return commonElements
}