JSFiddle - React, Tailwind, and code Playground

JavaScript

/*
Using the JavaScript language, have the function LetterCountI(str) take the str 
parameter being passed and return the first word with the greatest number of 
repeated letters. For example: "Today, is the greatest day ever!" should return 
greatest because it has 2 e's (and 2 t's) and it comes before ever which also 
has 2 e's. If there are no words with repeating letters return -1. Words will 
be separated by spaces. 

console.log(LetterCountI("Today, is the greatest day ever!") === "greatest");
console.log(LetterCountI("Hello apple pie") === "Hello");
console.log(LetterCountI("No words") === -1);

Tips: 
This is an interesting problem. What we can do is turn the string to lower case using String.toLowerCase, and then split on "", so we get an array of characters.

We will then sort it with Array.sort. After it has been sorted, we will join it using Array.join. We can then make use of the regex /(.)\1+/g which essentially means match a letter and subsequent letters if it's the same.

When we use String.match with the stated regex, we will get an Array, whose length is the answer. Also used some try...catch to return 0 in case match returns null and results in TypeError.

/(.)\1+/g with the match method will return a value of letters that appear one after the other. Without sort(), this wouldn't work.
*/

function LetterCountI(str){
  var wordsAndAmount={};
	var mostRepeatLetters="-1";
  var words=str.split(" ");
  
  words.forEach(function(word){
      var howManyRepeat=word.toLowerCase().split("").sort().join("").match(/([.])\1+/g).length; // returns value of how many repeated letters in word
			if(howManyRepeat !== null || howManyRepeat !== 0){ // if there are repeats(at least one value)..
    			wordsAndAmount[word] = howManyRepeat;
			}else{
          wordsAndAmount[word] = -1; // if no words have repeats will return -1 after for in loop.
      }
  });
  
	for(var word in wordsAndAmount){ // word is the key, wordsAndAmount[word] is the value of word.
   ...