From 2844c0e136724c67494453972c867571e6a61ec0 Mon Sep 17 00:00:00 2001 From: Thiago Bronisio <86695254+ThiagoBronisio@users.noreply.github.com> Date: Sat, 29 Oct 2022 00:26:14 -0300 Subject: [PATCH] feat(challenge) desafio mostRepeatedChar finalizado --- 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..9570bd8 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 maxChar = ''; + text.split('').forEach((char) => { + if(text.split(char).length > max){ + max = text.split(char).length - 1; + maxChar = char; + } + }) + return maxChar; } \ No newline at end of file