Skip to content

Commit e4888f4

Browse files
implemented fun makeAbbr()
1 parent 81f1eaa commit e4888f4

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
package mate.academy
22

3+
const val ONE = 1
4+
35
fun makeAbbr(source: String) : String {
4-
// implement this function
5-
return ""
6+
val result = mutableListOf<Char>()
7+
result.add(source.first())
8+
source.forEachIndexed { i, c ->
9+
if (c == ' ') {
10+
result.add(source[i + ONE])
11+
}
12+
}
13+
return result.toString()
14+
.replace(Regex("[^A-Za-z]"), "")
15+
.uppercase()
616
}

0 commit comments

Comments
 (0)