From e9f6faa98899dcc9bcbbcb0166868894c01ad9b7 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Mon, 31 Oct 2022 10:27:30 -0300 Subject: [PATCH] feat(monstUsedChar): Finaliza algoritmo --- 09-mostRepeatedChar/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..87367f7 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,17 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + + let max = 0; + let maxCaracter = ""; + + text.split('').forEach((caracter) => { + if (text.split(caracter).length > max) { + max = text.split(caracter).length; + + maxCaracter = caracter; + } + }); + + + return maxCaracter; } \ No newline at end of file