title: Putting switch case inside map function
body: <p>Is there a way to put a switch conditional inside this map function?<br />
  I want that<br />
  if row.role = 1, then put &quot;Student&quot; inside RoleIndex<br />
  if row.role = 2, then put &quot;Teacher&quot; inside RoleIndex and so on ....<br />
  But this code below give me syntax error</p>
  <pre><code>React.useEffect(() =&gt; {
      API.GetUser().then((result) =&gt; {
        console.log(result);
        setListUser(
          result.map((row) =&gt; ({
            IdIndex: row.id, // Ex: Receive 1
            NameIndex: row.name, // Ex: Receive Parker
            switch (row.role) {
              case 1:
              RoleIndex: &quot;Student&quot;
              break;
              case 2:
              RoleIndex: &quot;Teacher&quot;
              break;
              case 3:
              // do something
              break;
          }
          }))
        );
  
        setLoading(false);
      });
    }, [props]);
  </code></pre>