ScriptS
Reactiflux5y ago
30 replies
Script

Script – 13-35 Jan 19

I have this code which is supposed to return
lonely integers(the one that occurs once in the array)

function lonelyinteger(a) {
  let allA = [];
  let allB;

  for (i = 0; i < a.length; i++) {
    allA.push(a.filter((string) => string === a[i]));

    if (allA[i].length === 1) {
      allB = allA[i].toString();
    }
  }

  return allB;
}


It works perfectly but hacker rank keeps rejecting it and I'm not really sure why
This is the error I get
unknown.png
unknown.png
Was this page helpful?