Skip to content

Instantly share code, notes, and snippets.

@goofballLogic
Last active January 26, 2026 19:04
Show Gist options
  • Select an option

  • Save goofballLogic/e04744be0554eb67a2fe5765975079e5 to your computer and use it in GitHub Desktop.

Select an option

Save goofballLogic/e04744be0554eb67a2fe5765975079e5 to your computer and use it in GitHub Desktop.
const flippedy = str =>
str
?.split(" ")
.map(word => [
word.match(/[aeiou]/gi)?.length || 0,
word
])
.reduce((a, word, i) =>
i
? [
a[0],
`${a[1]} ${
word[0] === a[0]
? Array.from(word[1]).reverse().join("")
: word[1]}`
]
: word
)
[1]
|| str;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment