Simple JavaScript Solution
\nconst longestWord = (words) => {\n    words.sort()\n    const wordSet = new Set(words)\n    let res = ''\n    for (const w of words) {\n        let isValid = 
```\nconst longestWord = (words) => {\n    words.sort()\n    const wordSet = new Set(words)\n    let res = ''\n    for (const w of words) {\n        let isValid = true\n        let key = ''\n        for (let i = 0; i < w.length - 1; i++) {\n            key += w[i]\n            if (!wordSet.has(key)) {\n                isValid = false\n                break;\n            }\n        }\n        if (isValid && w.length > res.length) {\n            res = w\n        }\n    }\n    return res\n};\n```
['JavaScript']