Thanks to @ynndvn for showing me reduce method, it exist too in Swift language and it's awesome !!!
reduce
This is my solution in Swift :
func wordsToMarks(word: String) -> Int { return word.compactMap { $0 }.reduce(0) { $0 + Int($1.asciiValue ?? 0) - 96 } } wordsToMarks(word:"attitude") wordsToMarks(word:"friends") wordsToMarks(word:"family") wordsToMarks(word:"selflessness") wordsToMarks(word:"knowledge")
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks to @ynndvn for showing me
reduce
method, it exist too in Swift language and it's awesome !!!This is my solution in Swift :