/**
 * Calculate the total sales of a marketing campaign.
 *
 * Given a map of products and a target sales value, this function iterates through the products
 * and breaks the loop as soon as the cumulative sales value reaches or exceeds the target sales value.
 * It then returns the total sales achieved.
 *
 * @param products A map containing the product name as the key and the sales achieved as the value.
 * @param targetSales The desired sales goal to be achieved.
 * @return The total sales achieved.
 */
fun calculateTotalSales(products: Map<String, Int>, targetSales: Int): Int {

    var totalSales = 0

    for ((product, sales) in products) {
        if (totalSales >= targetSales) {
            break  // Exiting the loop if target sales are met or exceeded
        }

        totalSales += sales
    }

    return totalSales
}
/**
 * Calculate the total sales of a marketing campaign.
 *
 * Given a map of products and a target sales value, this function iterates through the products
 * and breaks the loop as soon as the cumulative sales value reaches or exceeds the target sales value.
 * It then returns the total sales achieved.
 *
 * @param products A map containing the product name as the key and the sales achieved as the value.
 * @param targetSales The desired sales goal to be achieved.
 * @return The total sales achieved.
 */
fun calculateTotalSales(products: Map<String, Int>, targetSales: Int): Int {
/**
 * Calculate the total sales of a marketing campaign.
 *
 * Given a map of products and a target sales value, this function iterates through the products
 * and breaks the loop as soon as the cumulative sales value reaches or exceeds the target sales value.
 * It then returns the total sales achieved.
 *
 * @param products A map containing the product name as the key and the sales achieved as the value.
 * @param targetSales The desired sales goal to be achieved.
 * @return The total sales achieved.
 */
fun calculateTotalSales(products: Map<String, Int>, targetSales: Int): Int {

    var totalSales = 0

    for ((product, sales) in products) {
        if (totalSales >= targetSales) {
            break  // Exiting the loop if target sales are met or exceeded
        }

        totalSales += sales
    }

    return totalSales
}