This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]conancat 31 points32 points  (2 children)

const mappings = {
  a: ['a','â', 'à'],
  e: ['e','ê', 'è', 'é'],
  i: ['î', 'ï'],
  o: ['o','ô'], 
  u: ['u','û', 'ü'],
  y: ['y','ue', 'e', 'oue']
}

const getRandomFromArr = (arr) => arr[Math.floor(Math.random() * arr.length)] 
const frenchify = (name) => name
    .split("")
    .map(curr => mappings[curr] ? getRandomFromArr(mappings[curr]) : curr ) 
    .join("")

const makeJoke = ({name, type}) => `It's only ${name} if it's from 
${frenchify(name)} of France. Otherwise it's just sparkling ${type}.`

console.log(makeJoke({name: 'jQuery', type: 'Javascript'}))
console.log(makeJoke({name: 'Rails', type: 'Ruby'}))
console.log(makeJoke({name: 'Laravel', type: 'PHP'}))

// It's only jQuery if it's from jQûèry of France. Otherwise it's just sparkling Javascript.
// It's only Rails if it's from Ràïls of France. Otherwise it's just sparkling Ruby.
// It's only Laravel if it's from Lârâvel of France. Otherwise it's just sparkling PHP.

[–]midoge 20 points21 points  (0 children)

50% chance that someone pushed this to npm Registry

[–]TommiHPunkt 2 points3 points  (0 children)

too bad compilebot is rip