So I was messing around with a simple javascript anagram function to compare 2 strings, however whenever I tried to use the .split operation in my sort function my code would error:
var wd;
function sortword(word){
wd = word;
var w = wd.split("");
w.sort();
return w;
}
caused
"TypeError: undefined is not an object (evaluating 'wd.split')"
http://jsbin.com/lebiwolive/1/edit?js,console
Why does this cause such an error? I've tried defining wd in various places but it does;t seem to make any difference. The code does even work correctly but I have this error in my console.