"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const leven_1 = __importDefault(require("leven"));
function autocorrect(inputWord, words) {
    let bestWord = null;
    let min = null;
    for (let i = 0; i < words.length; i++) {
        const word = words[i];
        const distance = leven_1.default(inputWord, word);
        if (distance === 0) {
            return word;
        }
        else if (!min || distance < min) {
            min = distance;
            bestWord = word;
        }
    }
    return bestWord;
}
exports.default = autocorrect;
//# sourceMappingURL=autocorrect.js.map