From e4e94adf5ef9f57d0769632d943aa5e376f2f1aa Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 16:16:15 -0300 Subject: [PATCH] feat(mostRepeatedChar): adiciona resolucao questao09-mostrepeatedchar --- 09-mostRepeatedChar/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..af729cd 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,12 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + let max = 0; + let maxRepeated = ''; + text.split('').forEach(function(char){ + if(text.split(char).length > max) { + max = text.split(char).length; + maxRepeated = char; + } + }); + return maxRepeated; } \ No newline at end of file