question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript: solution failed online but passed locally.

See original GitHub issue

Bug, timeout or some kind of change? Time took to run : 16.309 s.

const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

const random = (min: number, max: number /* max is exclusive */) =>
  Math.floor(Math.random() * (max - min) + min);

export class Robot {
  private static names = new Set();
  private robotName: string = "";

  constructor() {
    this.robotName = Robot.generateName();
  }

  public get name(): string {
    return this.robotName;
  }

  public resetName(): void {
    this.robotName = Robot.generateName();
  }

  public static releaseNames(): void {
    this.names.clear();
  }

  private static randomLetter(): string {
    return LETTERS[random(0, 26)];
  }

  private static randomDigit(): number {
    return random(0, 10);
  }

  private static generateName(): string {
    let name;
    do {
      name = [
        Robot.randomLetter(),
        Robot.randomLetter(),
        Robot.randomDigit(),
        Robot.randomDigit(),
        Robot.randomDigit(),
      ].join("");
    } while (Robot.names.has(name));
    Robot.names.add(name);
    return name;
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
SleeplessBytecommented, Dec 14, 2021

Should have been solved! If not, please comment here again so we can re-open.

1reaction
SleeplessBytecommented, Sep 18, 2021

Yeah, I’m not against that @bobahop 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: says passed tests but doesn't compile locally (and ...
This may be related, which is a solution which failed online but passed locally, including the optional test. I wonder if the commented...
Read more >
My code failed in pipeline but passed in local, why ... - YouTube
My code failed in pipeline but passed in local, why? ... 540 views 1 month ago Playwright framework - Typescript.
Read more >
Tests passing locally but failing with circleci Typescript issue
Hi guys, I have tests that are all passing locally, but when circleci runs the same tests they are failing. error: FAIL server/src/User-Server/test/routes.test....
Read more >
[ESLint] Passes locally but fails in CI : r/typescript - Reddit
When I run eslint locally for a PR I'm working on, everything passes but when it runs in the CI environment, one of...
Read more >
TypeScript errors and how to fix them
Common Errors​​ Below you find a list of common TypeScript errors along with the buggy code and its fixed version.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found