//我的代码如下:第二题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<p id="box"></p>
<script>
function compare(str, str1) {
var strone = str;
var strtwo = str1;
for(var i = 0;i<strone.length;i++){
for(var j=0;j<strtwo.length;j++){
if(strone.charAt(i) === strtwo.charAt(j)){
var strr1 = strone.split(`${strone.charAt(i)}`).join('');
var strr2 = strtwo.split(`${strtwo.charAt(j)}`).join('');
}
}
}
var arrNovel = [];
arrNovel.push(strr1);
arrNovel.push(strr2);
var result = arrNovel.join("");
var zsort = result.split("").sort();
var fsort = [];
for(var i= zsort.length-1;i>=0;i--){
fsort.push(zsort[i]);
};
var lastResult = zsort.concat(fsort).join("");
return lastResult;
}
window.onload = function () {
document.getElementById('box').innerHTML = compare("as123456dAf", "wqerd");
}
</script>
</body>
</html>