I'm reading on the map/reduce documentation and this particular string example doesn't make sense to me.
var toCode = function(char) {
return char.charCodeAt(0);
}
First, the thing that works. Why does it work? string is not an array.
var text = "Hello World";
var map = Array.prototype.map;
console.log(map.call(text, toCode));
Now, the thing that doesn't work. Isn't this exactly the same as above?
console.log(text.map(toCode));
I use www.codeacademy.com console to test and this is the error message:
TypeError: undefined is not a function (evaluating '"hello world".map(toCode)')
Thank you.