forked from M3-Academy/challenge-algorithms-v2.0
feat(10): finished
This commit is contained in:
parent
c9e9d4a2e0
commit
ac37e689f8
@ -5,7 +5,7 @@ export function mostUsedChar(text) {
|
||||
let mostUsed = '';
|
||||
text.split('').forEach((letter) => {
|
||||
if (text.split(letter).length > maxLetter) {
|
||||
maxLetter = text.split(letter).length - 1;
|
||||
maxLetter = text.split(letter).length;
|
||||
mostUsed = letter;
|
||||
}
|
||||
})
|
||||
|
@ -1,4 +1,13 @@
|
||||
export function longestWords(words) {
|
||||
// implementar logica aqui
|
||||
|
||||
return words.reduce((longest, sentence, i) => {
|
||||
if (!i || longest[0].length < sentence.length) {
|
||||
return [sentence];
|
||||
}
|
||||
if (longest[0].length === sentence.length) {
|
||||
longest.push(sentence);
|
||||
}
|
||||
return longest;
|
||||
}, []);
|
||||
}
|
Loading…
Reference in New Issue
Block a user