Return the first word with the greatest number of repeated letters

前端 未结 5 1208
慢半拍i
慢半拍i 2021-01-16 23:16

This is a question from coderbyte’s easy set. Many people asked about it already, but I’m really curious about what’s wrong with my particular solution (I know it’s a pretty

5条回答
  •  情深已故
    2021-01-17 00:00

    I think the problem is that you're placing the return statement inside your outermost loop. It should be inside your inner loop.

    So you have to place the return statement within the inner loop.

    Correct use of return

         if (countNew > count) {
           count = countNew; 
           word = arr[i];
         }
         return word;
        }
      }
    } 
    

提交回复
热议问题