Sounds like a job for regex.
I think this could do it:
// BAD CODE
function useRegex(input) {
let regex = /^<[a-zA-Z]+> <[a-zA-Z]+><[a-zA-Z]+>$/i;
return regex.test(input);
}
EDIT: seems like my idiot self has messed this one up. Don't use regex, as commented by someone else.
I personally hate regex, so here are some tools to help you
Website to help you get started
https://regexr.com/
And how to apply that in Javascript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Regex code creator. It's like magic
https://regex-generator.olafneumann.org/