Of the two lines, for example, "xY12aabbbcc: c" and "xxx0xYYYYab; $$" which the user enters, you must output one, so that the elements of the line do not repeat, are in lower case and sorted. This line should contain only letters. Tell me please do I fix my code?
function string(form) { var firstString = form.first_string.value; var secondString = form.second_string.value; var firstPlusSecond = ((firstString + secondString).toLowerCase()); var first_plus_second = unique(firstPlusSecond).replace(/[^A-Za-z]/g, ""); function unique(arr) { var obj = {} for (var i = 0; i < arr.length; i++) { var str = arr[i]; obj[str] = true; } return Object.keys(obj); } alert(first_plus_second); } <!DOCTYPE html> <html> <head> </head> <body> <form> <p> <input type="text" name="first_string"> </p> <p> <input type="text" name="second_string"> </p> <button type="button" onclick="string(form)"> Match </button> </form> <script type="text/javascript"> </script> </body> </html>