JSFiddle - React, Tailwind, and code Playground

by roshan100kar

JavaScript

var text = "World War II";

for(var i = 0; i <= text.length; i++) {
  if(text.slice(i, i + 12) === "World War II") {
    text = text.slice(0, i) + "second World War" + text.slice(i + 12);
  }
}
console.log(text);