func solution(_ s:String) -> String {
var words = s.components(separatedBy:" ")
var result = [String]()
for index in 0..<words.count {
var array = Array(words[index])
(0..<array.count).map{
print(type(of:array[$0]))
if $0 % 2 == 0 {
array[$0] = Character(array[$0].uppercased())
} else {array[$0] = Character(array[$0].lowercased())}
}
result.append(array.map{String($0)}.joined(separator:""))
//print(array.map{String($0)}.joined(separator:""))
//print(array.joined(separator:""))
//words[index] = array.joined()
}
return result.joined(separator:" ")
}
func solution(_ s:String) -> String {
let a = s.components(separatedBy: " ").map { $0.enumerated().map { $0.offset % 2 == 0 ? $0.element.uppercased() : $0.element.lowercased() } }
return a.map{$0.joined()}.joined(separator: " ")
}
깨달은것: