code: function findChangedIndex(prevValue, newValue) {
    var i = 0,
        j = 0;
    var prevLength = prevValue.length;
    var newLength = newValue.length;
  
    while (prevValue[i] === newValue[i] && i < prevLength) {
      i++;
    } //check what has been changed from last
  
  
    while (prevValue[prevLength - 1 - j] === newValue[newLength - 1 - j] && newLength - j > i && prevLength - j > i) {
      j++;
    }
  
    return {
      start: i,
      end: prevLength - j
    };
  }
docs: Given previous value and newValue it returns the index
  start - end to which values have changed.
  This function makes assumption about only consecutive
  characters are changed which is correct assumption for caret input.