DEV Community

loading...

Discussion on: Daily Challenge #307 - Spanish Conjugator

Collapse
aminnairi profile image
Amin

CoffeeScript

conjugate = (verb) ->
  base    = verb[...-2]
  prepend = (words) -> "#{base}#{suffix}" for suffix in words

  switch verb[-2..]
    when "ir"
      prepend ["o", "es", "e", "imos", "ís", "en"]

    when "ar"
      prepend ["o", "as", "a", "amos", "áis", "an"]

    else
      prepend ["o", "es", "e", "emos", "éis", "en"]
Enter fullscreen mode Exit fullscreen mode