first line asks a question putting whatever is typed in into the 'text' variable.
the next line finds the first instance of "World War II" in that 'text' and puts that into the 'firstChar' variable. The 'indexOf' function will return -1 if there is no match.
The 'IF' statement checks if it's not -1, in which case there was a match.
... so it then uses 'slice' to take all text before the match, plug in "the Second World War", then all text after the match.
Next we close the if statement with }
Then we alert the result.
Which is a VERY complex way of simply going:
var text = prompt("What is this ?").replace(
'World War II', 'the Second World War'
Though a more complex regex would probably be in order.