//Write a JavaScript function that generates all combinations of a string. function substrings(str1) { var array1 = []; for (var x = 0, y=1; x < str1.length; x++,y++) { array1[x]=str1.substring(x, y); } var combi = []; var temp= ""; var slent = Math.pow(2, array1.length); for (var i = 0; i < slent ; i++) { temp= ""; for (var j=0;j