Say I have a string that contains a domain:
var domain = "http://google.com";
Each time the script runs, I would like to break this script into two parts at random.
So if I were to run it the first time, it could give me these results:
part 1: http://go
part 2: ogle.com
The second run would produce:
part 1: http://goog
part 2: le.com
at complete random each time.
How can I accomplish this?
Generate a random number between 0 and the string length. Grab a substring from that.
Demo: http://jsfiddle.net/KTPXt/