Couldn’t manage chaining calls using coffee script.
I’m trying to reproduce this in coffee script:
function htmlEscape(str) {
return String(str)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '<')
.replace(/>/g, '>');
}
I’m trying this way:
htmlEscape = (str) ->
String(str)
.replace (a,b)
.replace (c,d)
receiving an Parse error on line 13: Unexpected ',' error.
Could anyone help me with the proper chaining syntax?
You must remove these spaces (and probably put an space after the comma):
Or:
I like the second. Note you can abstract what you are doing using
reduce.