New snipper
coralhayoun opened this issue · 3 comments
coralhayoun commented
Hi,
I've wnated to add a new snipper called countStringOccurrences, which counts the occurrences of a string in another string
for examle: 'tt' occurs twice at 'attbtt'
right now theres only countOccurrences of an item in an array
is it ok to add it?
Chalarangelo commented
Thanks for asking. countOccurences
will work with strings if spread to arrays ([...str]
), so it's pretty much the same snippet in reality, so we shouldn't add one more for strings.
coralhayoun commented
spread it to array would help you find character occurences but not another string occurences
Trinityyi commented
@coralhayoun Fair enough, String.prototype.search()
orString.prototype.indexOf()
in combination with String.prototype.split()
will most likely do the trick then.