From 0295676121233a853fc7878556f1651b97a6c5d6 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:44:38 -0400 Subject: [PATCH] =?UTF-8?q?feat(mostUsedChar):=20fazendo=20func=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 09-mostRepeatedChar/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..fbde00f 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,10 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" -} \ No newline at end of file + // implementar logica aqui + let textLower = text.toLowerCase().split("").sort(); + for (let index = 1; index < textLower.length; index++) { + textLower = textLower.filter((e, i, a) => a.indexOf(e) !== i); + } + + let letter = [...new Set(textLower)]; + return letter.join(""); +}