Function works on CodePen but not in Node?

Hello,
I have this function :

let formatDate = (dt) => { 
    let date = new Date(dt).toLocaleDateString().replaceAll("/", ".") 
    return date + "."
}

The problem I have is that when I use it in Code Pen and on another computer it works just fine but when I use it on this PC, I get this error message:
TypeError: (intermediate value).toLocaleDateString(...).replaceAll is not a function.

replaceAll is new-ish, not sure which versions of Node supports it. I would have to check.

Edit: looks like 15.14.0 and above

https://node.green/#ES2021-features--String-prototype-replaceAll

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.