src/index.js
function _createSpotInEnteredMagicWords(spot, chars) {
  const firstChar = chars.substring(0, 1)
  const remainingChars = chars.substring(1)
  const nextSpot = (spot[firstChar] = spot[firstChar] || {})
  if (remainingChars) {
    return _createSpotInEnteredMagicWords(nextSpot, remainingChars)
  } else {
    return nextSpot
  }
}
function _createSpotInEnteredMagicWords(spot, chars) {
  const firstChar = chars.substring(0, 1)
  const remainingChars = chars.substring(1)
  const nextSpot = (spot[firstChar] = spot[firstChar] || {})
  if (remainingChars) {
    return _createSpotInEnteredMagicWords(nextSpot, remainingChars)
  } else {
    return nextSpot
  }
}
function _createSpotInEnteredMagicWords ( spot , chars ) { const firstChar = chars . substring ( 0 , 1 ) const remainingChars = chars . substring ( 1 ) const nextSpot = ( spot [ firstChar ] = spot [ firstChar ] || { } ) if ( remainingChars ) { return _createSpotInEnteredMagicWords ( nextSpot , remainingChars ) } else { return nextSpot } }
Recursively creates a new object property if one does not exist
for each character in the chars string.
@param {object} spot
@param {string} chars
@returns {object} - the final object.
@private
Recursively creates a new object property if one does not exist for each character in the chars string .