Q:

how to ensure that my string have two word in typescript

How do I ensure that my string have two words in it using typescript. 
The reason I need this so that I would call server only if name is in "first last" name format. 

A:

The answer really isn't TypeScript dependent. It's basic JavaScript.
You can use a regular expression to perform a test on the string:

function testString(input){
 // Return whether or not there are letters (any amount and any case)
 // followed by one space and then more letters (any amount and any case).
 // Of course, if you wanted to get more specific about case or character
 // counts, adjusting the regular expression would be simple.
 return /^[A-Za-z]+ [A-Za-z]+$/.test(input);
}

console.log(testString("Scott"));
console.log(testString("Scott Marcus"));
console.log(testString("Scott\nMarcus"));

