Conversation
|
Hey Like I said on the first challenge, Put the question in the description. I don't have access to the question. I have to look at what the question to determine whether what you are doing is what the question wants or if there is a better way of doing it |
| // removing duplicate vowels from the string | ||
| const uniqueVowels = [...new Set(vowels)].join(""); | ||
| // getting duplicates from the original string | ||
| const numberOfDuplicates = name |
There was a problem hiding this comment.
Good job on this.
But we are splitting lucky enough using an empty delimiter which is O(StringLength), then sorting, then joining and matching. These can be expensive operations if we have very long strings, Can you think of a way you can count duplicates in a string without doing all those operations?
|
I noticed that you don't have tests for this challenge. Can you write unit tests for your code? |
dennisja
left a comment
There was a problem hiding this comment.
Let's Just Add tests for this and get it merged
| // removing duplicate vowels from the string | ||
| const uniqueVowels = [...new Set(vowels)].join(""); | ||
| // getting duplicates from the original string | ||
| const numberOfDuplicates = name |
@dennisja plz review the second challenge for week two.
qn
Write a function that takes a string and returns an array of length 2 containing a new
string made of all and only the vowels from the original string and the number of duplicates in the original string. Only the first instance of the vowel is considered.
For example:
countVowels(‘dahdah’) # will return (‘a’, 3)
countVowels(‘drink water’) # will return (‘iae’, 1)