JSFiddle - React, Tailwind, and code Playground

by anton_F

JavaScript

const firstWord = words.split(' ')[0];
  const lastWord = words.split(' ')[1];
  const firstWordIndex = words.indexOf(firstWord);
  const lastWordIndex = words.indexOf(lastWord);
  const intoPhrase = firstWord + ' ' + replacement + ' ' + lastWord;
  
  const joinUp = phrase.join(intoPhrase)

  console.log(joinUp)
}