title: How can I remove whitespace from a pathname in react
body: <p>The menu items in my dropdown are stored in an array called &quot;lis&quot;. When the dropdown is open, the lis are mapped into it. Now I want to take the names not only as content, but also as a path to open the pages. And it works. My only problem is that some of the lis consist of two words. And I can't have a pathname with spaces. How can I remove this whitespace?
  I tried to predefine it with lis.join(&quot;&quot;), but the console tells me, undefined, so I obviously must find a way to do that in the map function.</p>
  <p>code:</p>
  <pre><code>{
   item.lis.map((li, index)=&gt;(
      &lt;ul key={index}&gt;
       &lt;DropDownLi&gt;&lt;Link to={{pathname:`/${li}`}} className=&quot;link&quot; style={{color:&quot;black&quot;}}&gt;{li}&lt;/Link&gt;&lt;/DropDownLi&gt;
      &lt;/ul&gt;
       ))
  }
  </code></pre>