function scramble(a){a=a.split("");for(var b=a.length-1;0<b;b--){var c=Math.floor(Math.random()*(b+1));d=a[b];a[b]=a[c];a[c]=d}return a.join("")}
I've got this code, which seems to be effective in scrambling a single word by calling an alert:
alert(scramble('Like this.'));
Here's what I'm trying to do though: I want to be able to enter text in a textarea, separated by newlines, and randomly scramble each string line by line. For example:
testing
scramble
words
Would output something like:
sgnitte
rceamslb
dwros
Can anyone help me in doing this?