Created
August 17, 2014 23:01
-
-
Save alexanderGugel/9e9067231cb4abbb130e to your computer and use it in GitHub Desktop.
Domainhacks
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
var fs = require('fs'); | |
var words = fs.readFileSync('/usr/share/dict/words', { | |
encoding: 'utf8' | |
}).split('\n'); | |
var tlds = ['co', 'com', 'io', 'de', 'it']; | |
var results = []; | |
for (var i = 0; i < words.length; i++) { | |
var wordArray = words[i].split(''); | |
for (var j = 0; j < tlds.length; j++) { | |
var tld = tlds[j]; | |
var lastLetters = wordArray.slice(-tld.length).join(''); | |
if (lastLetters === tld) { | |
wordArray.splice(-tld.length, 0, '.'); | |
results.push(wordArray.join('')); | |
} | |
} | |
} | |
console.log(results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment