-
Notifications
You must be signed in to change notification settings - Fork 0
/
kata.js
39 lines (24 loc) · 815 Bytes
/
kata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function spinWords(string) {
return string.split(' ')
.map(i => {
if (i.length < 5) {
return i
} else {
return i.split('').reverse().join('');
}
}).join(' ')
}
console.log(spinWords("Welcome"));
// "emocleW"
console.log(spinWords("Hey fellow warriors"));
// "Hey wollef sroirraw"
console.log(spinWords("This is a test"));
// "This is a test"
console.log(spinWords("This is another test"));
// "This is rehtona test"
console.log(spinWords("You are almost to the last test"));
// "You are tsomla to the last test"
console.log(spinWords("Just kidding there is still one more"));
// "Just gniddik ereht is llits one more"
console.log(spinWords("Seriously this is the last one"));
// "ylsuoireS this is the last one"