• get closest string from dict

    Parameters

    • input: string
    • dict: string[]
       const dict = ['hello', 'haha', 'mama', 'moment', 'world', 'latest'];

      expect(closest('h', dict)).toBe('haha');
      expect(closest('he', dict)).toBe('hello');
      expect(closest('m', dict)).toBe('mama');
      expect(closest('mo', dict)).toBe('mama');
      expect(closest('mome', dict)).toBe('mama');
      expect(closest('latast', dict)).toBe('latest');

    Returns string

    5.16.0