Answer:
The indexOf is a string method used to get the index of a character in a string. It can be used with the slice, substr, or subString methods to divide a string into two or more parts.
var words = "hello John Snow";
var A = words.slice(0, words.indexOf("John"));
var B = words.slice(words.indexOf("John") + 1, words.length());
One (1) is added to the space of avoid repeating a character in both new strings.
Step-by-step explanation:
The indexOf method is a built-in method in Javascript used to get the index of a character or word in a string variable. The return integer number can be used in a method like a slice() to divide the string and them to other string variables.