src/index.js
function _stringsByCharOrder(magicWord, givenMagicWord) {
  let charNumber = 0

  function _findMatchingCharacter(matchChar, string) {
    let found = false
    for (let j = charNumber; j < string.length; j++) {
      const stringChar = string[j]
      if (stringChar === matchChar) {
        found = true
        charNumber = j + 1
        break
      }
    }
    return found
  }

  for (let i = 0; i < givenMagicWord.length; i++) {
    const matchChar = givenMagicWord[i]
    const found = _findMatchingCharacter(matchChar, magicWord)
    if (!found) {
      return _matchRankMap.noMatch
    }
  }
  return _matchRankMap.matches
}
function _stringsByCharOrder(magicWord, givenMagicWord) {
  let charNumber = 0

  function _findMatchingCharacter(matchChar, string) {
    let found = false
    for (let j = charNumber; j < string.length; j++) {
      const stringChar = string[j]
      if (stringChar === matchChar) {
        found = true
        charNumber = j + 1
        break
      }
    }
    return found
  }

  for (let i = 0; i < givenMagicWord.length; i++) {
    const matchChar = givenMagicWord[i]
    const found = _findMatchingCharacter(matchChar, magicWord)
    if (!found) {
      return _matchRankMap.noMatch
    }
  }
  return _matchRankMap.matches
}
function _stringsByCharOrder ( magicWord , givenMagicWord ) { let charNumber = 0 function _findMatchingCharacter ( matchChar , string ) { let found = false for ( let j = charNumber ; j < string . length ; j ++ ) { const stringChar = string [ j ] if ( stringChar === matchChar ) { found = true charNumber = j + 1 break } } return found } for ( let i = 0 ; i < givenMagicWord . length ; i ++ ) { const matchChar = givenMagicWord [ i ] const found = _findMatchingCharacter ( matchChar , magicWord ) if ( ! found ) { return _matchRankMap . noMatch } } return _matchRankMap . matches }
Returns a _matchRankMap.matches or noMatch score based on whether
the characters in the givenMagicWord are found in order in the
magicWord
@param {string} magicWord
@param {string} givenMagicWord
@returns {number}
@private
Returns a _matchRankMap . matches or noMatch score based on whether the characters in the givenMagicWord are found in order in the magicWord