javascript
/**
* @param {string[]} words
* @return {string[]}
*/
var findWords = function (words) {
let result = []
const lines = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm']
words.forEach((word) => {
const item = word.toLowerCase()
let charLine = ''
const flag = item.split('').every((char) => {
if (charLine === '') {
if (lines[0].includes(char)) {
charLine = lines[0]
} else if (lines[1].includes(char)) {
charLine = lines[1]
} else if (lines[2].includes(char)) {
charLine = lines[2]
}
return true
} else {
return charLine.includes(char)
}
})
if (flag) {
result.push(word)
}
})
return result
}