Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to generate titles for Forbes articles
Array.prototype.randChoice = function() {
return this[~~(Math.random() * this.length)];
}
const sel_opts = [
["Google", ["Chrome", "Android"]],
["Microsoft", ["Edge", "Windows"]],
["Apple", ["iPhone"]],
["Facebook", ["Facebook", "Instagram"]]
];
const genTitle = () => {
let [mfg, product] = sel_opts.randChoice();
product = product.randChoice();
return `${mfg} Just Gave Millions Of Users A Reason To ${["Start", "Stop"].randChoice()} Using ${product}`;
}
// Test
for (let count=0; count<5; count++) {
console.log(genTitle());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment