JSFiddle - React, Tailwind, and code Playground

by Dmitry Morar

JavaScript

function fearNotLetter(str) {
  
  const arrByStr = str.split(''); //['s','t','v','w','x']
  
  const ethalonArr = 'abcdefghijklmnopqrstuvwxyz'.split(''); 
  //['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
  
  
	// arrByStr[0] => 's'
  //находим какой индекс у 'S' в алфавите (ethalonArr)
  const startIndex = ethalonArr.indexOf(arrByStr[0]);
  
  let j = 0;
  str = undefined;

	//сохраняем в i индекс буквы 'S' что бы начать сравнивать именно с нее
  for(let i = startIndex; i <= ethalonArr.length; i++) {
			
      if(arrByStr[j] != ethalonArr[i]) {
        str = ethalonArr[i]
        break;
      }
      j++;
  }

  return str;
}

console.log(fearNotLetter("stvwx"));