OneCompiler

Write a Swift program to add "Is" to the front of a given string. However, if the string already begins with "Is", return the given string.

112

import Foundation
func isstring(word: String) -> String {
if word.hasPrefix("Is") == true
{
return word
}
else
{
return "Is (word)"
}
}

print(isstring(word: "Is Swift"))
print(isstring(word: "Swift"))