Is there a name for functions that chooses and returns one of its arguements by one of its arguements like "switch"?

Viewed 32

I am making functions that work like switch.

For example, it receives four arguements. The first arguement is one of 'a','b','c', and it works like below.

(s, o1, o2, o3)=>{
  if(s==='a'){
    return o1 
  } else if (s==='b'){
    return o2 
  }else if (s==='c'){
    return o3 
  }
}

I have several functions that work like this, and would like to know if there is name for these, so that at least I can place them in one dir

0 Answers
Related