Sort and Star
You will be given a list of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value.
The returned value must be a string, and have "***" between each of its letters.
You should not remove or add elements from/to the array.
function twoSort(s: string[]): string {
return s.sort()[0].split('').join('***');
}
console.log(twoSort(['banana','apple']));
package main
import (
"fmt"
"sort"
"strings"
)
func twoSort(s []string) string {
sort.Strings(s)
return strings.Join(strings.Split(s[0], ""), "***")
}
func main() {
fmt.Println(twoSort([]string{"banana", "apple"}))
}
def two_sort(array):
return '***'.join(min(array))
print(two_sort(['banana','apple']))
function twoSort($s) {
sort($s);
return implode('***', str_split($s[0]));
}
echo twoSort(['banana','apple']);
Go to Kata
Want us to give you some help with your business? No problem, here's a video on who we can help, and how, along with our calendar so you can book in a call to discuss us working together.
Let's see