Light Mode
Dark Mode
I also have problems with the tests

Local test are running correct and complete, but server returns error after clicking 'check': Can someone help me to fix this problem?

"use strict";

function mostWanted(data) {
  const d = data.toLowerCase().split('').sort().join('');
  let regexp = /(?=([a-z]))\1{1,}/g;
  let matchesArr = d.match(regexp);

  matchesArr.sort((a, b) => {
    return b.length - a.length;
  });

  return matchesArr[0][0];
}

var assert = require('assert');

if (!global.is_checking) {
    assert.equal(mostWanted("Hello World!"), "l", "1st example");
    assert.equal(mostWanted("How do you do?"), "o", "2nd example");
    assert.equal(mostWanted("One"), "e", "3rd example");
    assert.equal(mostWanted("Oops!"), "o", "4th example");
    assert.equal(mostWanted("AAaooo!!!!"), "a", "Letters");
    console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
Attachment
  • task.most-wanted-letter
Created: April 16, 2020, 8:16 a.m.
Updated: April 16, 2020, 11:49 a.m.
0
1
User avatar
hawkite25