left()

var name = "Mr Smith"
var title = String.left(name,2)

Note:
The Return Value in the example above would be "Mr". Therefore, the variable title will contain the value "Mr".

Close