I am looking to take a string and find all the spaces in it and separate that into different variables. I know I could use the .split() but that wouldn\'t make
.split()
.split() just returns an array, so you can easily assign new variables using that...
var str = "John M Peters"; var fname = str.split(" ")[0]; var mname = str.split(" ")[1]; var lname = str.split(" ")[2];