This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOneKeyRowWords(listOfWords) { | |
const row1 = ['q','w','e','r','t','y','u','i','o','p'], | |
row2 = ['a','s','d','f','g','h','j','k','l'], | |
row3 = ['z','x','c','v','b','n','m']; | |
return listOfWords.filter((word) => { | |
const uniquesChars = new Set(word.toLowerCase()); | |
return ( | |
row1.length === [...new Set([...row1, ...uniquesChars])].length || | |
row2.length === [...new Set([...row2, ...uniquesChars])].length || | |
row3.length === [...new Set([...row3, ...uniquesChars])].length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isFactorial(num) { | |
let remainder = num; | |
let factorial = 2; | |
while(remainder >= factorial) { | |
remainder = remainder/factorial; | |
factorial++; | |
} | |
return remainder===1; | |
} |