[Solved] I want to just use a simple for loop


You are trying to achieve the following:

import Foundation

let input = ["VALUE ACTIVITY", "BONUS ACTIVITY", "JACKPOT EVENTS", "VALUE ACTIVITY", "JACKPOT EVENTS"]

var output = [String]()

for element in input {
    if element.contains("VALUE ACTIVITY") {
        output.append(element.replacingOccurrences(of: "VALUE ACTIVITY", with: "Value"))
    } else if element.contains("JACKPOT EVENTS") {
        output.append(element.replacingOccurrences(of: "JACKPOT EVENTS", with: "Jackpot"))
    } else if element.contains("BONUS ACTIVITY") {
        output.append(element.replacingOccurrences(of: "BONUS ACTIVITY", with: "Bonus"))
    } else {
        output.append(element)
    }

}

print(output)

But in your specific case you could use a much shorter and more efficient solution:

import Foundation

let input = ["VALUE ACTIVITY", "BONUS ACTIVITY", "JACKPOT EVENTS", "VALUE ACTIVITY", "JACKPOT EVENTS"]

let output = input.map { $0.prefix(1).uppercased() + $0.split(separator: " ")[0].lowercased().dropFirst() }

print(output)

0

solved I want to just use a simple for loop