When I use only sort() without arguments, it returns correctly in alphabetical order. When I try to add in arguments like below, it just returns the word in the same order the string was entered in. I'm not entirely sure what I'm doing incorrectly.
var a = str.split("")
return a.sort((a,b) => a-b).join("");
a - bisNaNwhenaandbare non-numeric strings. What are you trying to achieve?return a.sort((a,b) => a > b ? 1 : -1).join(""); should do itvar array = ['c','d','a']thenarray.sort(), it returns['a',''b','c']...i was wondering why when adding the arguments, it doesn't achieve the same thing