Currently, I am developing a web application that involves a calculation method which takes a string as input and returns the number of SMS messages. This function is self-contained and does not rely on any external resources to operate.
I need this function to be functional both in the client-side for displaying the message's SMS count to users and in the server-side for calculating the cost associated with the message transmission.
Initially, my plan was to create a C# version of the function for server-side operations and a separate JavaScript version for client-side functionality. But then I had a 'DRY' moment - What if it's possible to execute JavaScript functions on the server-side as well? I'm uncertain about the feasibility of this approach.
So, here's my question: Is it achievable to run a JavaScript function on the server-side, or perhaps from a class library?