DEV Community

loading...

Discussion on: Daily Challenge #307 - Spanish Conjugator

Collapse
alvaromontoro profile image
Alvaro Montoro

In JavaScript:

const conjugate = verb => {
  switch(verb.slice(-2)) {
    case "ar": return ["o","as","a","amos","ais","an"].map(el => verb.slice(0, verb.length-2) + el);
    case "er": return ["o","es","e","emos","eis","en"].map(el => verb.slice(0, verb.length-2) + el);
    case "ir": return ["o","es","e","imos","is","en"].map(el => verb.slice(0, verb.length-2) + el);
  };
}
Enter fullscreen mode Exit fullscreen mode