/**
 * This exercise requires you to find the common elements between two lists and return a new list containing those elements.
 *
 * Instructions:
 * - Loop through each element in list1.
 * - Use the 'in' operator to check if the element is present in list2.
 * - If the element is present in list2, append it to a new list called commonElements.
 * - Finally, return the commonElements list.
 *
 * Example:
 * For list1 = [1, 2, 3, 4, 5] and list2 = [2, 4, 6, 8], the common elements are [2, 4].
 *
 * Your task is to write the Kotlin code to solve this exercise.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

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

    return commonElements
}
/**
 * This exercise requires you to find the common elements between two lists and return a new list containing those elements.
 *
 * Instructions:
 * - Loop through each element in list1.
 * - Use the 'in' operator to check if the element is present in list2.
 * - If the element is present in list2, append it to a new list called commonElements.
 * - Finally, return the commonElements list.
 *
 * Example:
 * For list1 = [1, 2, 3, 4, 5] and list2 = [2, 4, 6, 8], the common elements are [2, 4].
 *
 * Your task is to write the Kotlin code to solve this exercise.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This exercise requires you to find the common elements between two lists and return a new list containing those elements.
 *
 * Instructions:
 * - Loop through each element in list1.
 * - Use the 'in' operator to check if the element is present in list2.
 * - If the element is present in list2, append it to a new list called commonElements.
 * - Finally, return the commonElements list.
 *
 * Example:
 * For list1 = [1, 2, 3, 4, 5] and list2 = [2, 4, 6, 8], the common elements are [2, 4].
 *
 * Your task is to write the Kotlin code to solve this exercise.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

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

    return commonElements
}