Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions codewars/7kyu/apparently-modifying-strings/koronya.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// [JS][7kyu] Apparently-Modifying Strings
// apparently-modifying-strings
// https://www.codewars.com/kata/5b049d57de4c7f6a6c0001d7/train/javascript

const apparently = (string) => {
const arr = string.split(' ')
return arr
.map((word, index) => {
if ((word === 'and' || word === 'but') && arr[index + 1] !== 'apparently') {
return word + ' apparently'
}
return word
})
.join(' ')
}

apparently('It was great and I have never been on live television before but sometimes I dont watch this.') ===
'It was great and apparently I have never been on live television before but apparently sometimes I dont watch this.'
apparently('and') === 'and apparently'
apparently('apparently') === 'apparently'

apparently('but but but and and and')