title: Trying to return <spans> from a series of loops/maps in Javascript
body: <p>I am trying to break up an inputted string and then iterate through an array of objects to match each part of the string to a series of spellings (you can see the data structure below). However I am just returning <code>undefined</code> it seems.</p>
  <p>Here is my redux code</p>
  <pre><code>
  const wordSlice = createSlice({
    name: 'word',
    initialState: { word: '', preppedWord: '' },
    reducers: {
      [...]
      checkPhonemes(state, action) {
        console.log(decoder.phonemeCheck(state.word))
        state.preppedWord = decoder.phonemeCheck(state.word)
      },
    },
  })
  </code></pre>
  <p>Here are the relevant functions:</p>
  <pre><code>export const phonemeCheck = (word) =&gt; {
    return phonemeMatcher(word)
  }
  
  ///map((element) =&gt; { /* … */ })
  export const phonemeMatcher = (word) =&gt; {
    for (let i = 0; i &lt; word.length; i++) {
      for (let j = 0; j &lt; word.length - i; j++) {
        let chunk = word.substring(i, i + j + 1)
        consonants.map((consonant) =&gt; {
          consonant.spellings.map((spelling) =&gt; {
            if (chunk === spelling.spelling) {
              console.log(chunk)
              return &lt;span className={'phoneme-class'}&gt;{chunk}&lt;/span&gt;
            }
          })
        })
      }
    }
  }
  </code></pre>
  <p>Here is the data (excerpt)</p>
  <pre><code>export const consonants = [
    //remember to wrap sounds in / / eg. /s/, /c/
    {
      consonantSound: 's',
      spellings: [
        { spelling: 's', example: 'sun' },
        { spelling: 'ss', example: 'class' },
        { spelling: 'c', example: 'cell' },
        { spelling: 'ce', example: 'voice' },
        { spelling: 'se', example: 'house' },
        { spelling: 'sc', example: 'scent' },
      ],
    },
    {
      consonantSound: 'sh',
      spellings: [
        { spelling: 'sh', example: 'ship' },
        { spelling: 'ch', example: 'machine' },
      ],
    },
    {
      consonantSound: 'ch',
      spellings: [
        { spelling: 'tch', example: 'match' },
        { spelling: 'ch', example: 'chips' },
      ],
    },
  [..]
  ]
  </code></pre>
  <p>Here is a fiddle <a href="https://jsfiddle.net/hs3nam5v/9/" rel="nofollow noreferrer">https://jsfiddle.net/hs3nam5v/9/</a></p>