Created
April 1, 2014 21:20
-
-
Save PhilKershaw/9923453 to your computer and use it in GitHub Desktop.
Simple string interleaving. The resultant string will be as long as the shortest stringx2 and as an added bonus the penultimate character of the first string is appended to the end. All in raw JavaScript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var string1 = 'ARNFH-U-5728'; | |
var string2 = 'SO06DNV'; | |
var array1 = string1.split(''); | |
var array2 = string2.split('').reverse(); | |
var obfuscated = ''; | |
array1.every(function(e, i, a) { | |
if (typeof array2[i] === 'undefined') { | |
obfuscated += array1[(array1.length - 1)]; | |
return false; | |
} | |
obfuscated += e + array2[i]; | |
return true; | |
}); | |
//console.log(obfuscated); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment