/**
 * Given two lists, find the common elements between them and return them as a new list.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Exercise:
 * Your task is to complete the code by implementing the loop and break statement to
 * find the common elements between list1 and list2 and return them as a new list.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()
    
    // Loop through list1
    for (element in list1) {
        // Loop through list2
        for (compare in list2) {
            // Compare elements
            if (element == compare) {
                // Append common element to the result list
                commonElements.add(element)
                break  // Add a break statement here (1 line)
            }
        }
    }
    
    return commonElements
}
/**
 * Given two lists, find the common elements between them and return them as a new list.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Exercise:
 * Your task is to complete the code by implementing the loop and break statement to
 * find the common elements between list1 and list2 and return them as a new list.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, find the common elements between them and return them as a new list.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Exercise:
 * Your task is to complete the code by implementing the loop and break statement to
 * find the common elements between list1 and list2 and return them as a new list.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()
    
    // Loop through list1
    for (element in list1) {
        // Loop through list2
        for (compare in list2) {
            // Compare elements
            if (element == compare) {
                // Append common element to the result list
                commonElements.add(element)
                break  // Add a break statement here (1 line)
            }
        }
    }
    
    return commonElements
}