Reputation: 659
This might be a dumb question, but how to I add space gaps using split. I know it returns as an array, so I am not sure if its what I want to do. But this is what I am using right now:
var GetME = $("#textinput").val().split(" ");
So for example, give if the user inputs TEXTTEST, I want the GetMe var to hold T E X T T E S T, is this possible?
Thanks Glenn
Upvotes: 2
Views: 62
Reputation: 207511
Use split("")
without the space to break up the string into the array. If you want to add spaces in between each letter, use join(" ")
"abcdefghij".split(""); //["a","b","c","d","e","f","g","h","i","j"]
"abcdefghij".split("").join(" "); // "a b c d e f g h i j"
Upvotes: 9