Skip to content

Instantly share code, notes, and snippets.

View Delni's full-sized avatar

Nicolas Delauney Delni

View GitHub Profile
const isVowel = (c: string) => 'aeiouy'.includes(c)
const yay = (word: string) => word + (isVowel(word[word.length - 1]) ? 'y' : '') + 'ay'
const isUpperString = (c: string) => c === c.toUpperCase()
const hasUpperCharacter = (word: string) => word.split('').find(isUpperString)
const restablishCase = (word: string) => hasUpperCharacter(word)
? word[0].toUpperCase() + word.substring(1).toLowerCase()
: word;
const toPigLatinWord = (word: string) => {
@Delni
Delni / pure_functions.ts
Last active September 1, 2020 19:42
Example of pure functions
let x: number = 0
// Fonction pure: ne modifie pas x
function add(value: number) {
return x + value
}
// Fonction impure: modifie x
function incrementBy(value: number) {
x += value;