I have JS code which I am trying to convert to C#. For some reason my C# method is returning 10 less than the return value of the JS function. I have tried changing multiple things and also checking the meaning of the && operator in JS but can't seem to figure out what I am doing wrong.
The correct return value is 97.
JavaScript Function & Usage:
function rir(t, e, c, n) {
return t > e
&& t <= c
&& (t += n % (c - e)) > c
&& (t = t - c + e),
t
}
rir('a'.charCodeAt(0), 47, 57, 'b'.charCodeAt(0));
/* returns 97 */
C# Method & Usage:
public int Rir(int t, int e, int c, int n)
{
if (t > e && t <= c)
t += (n % (c - e));
if (t > c)
t = ((t - c) + e);
return t;
}
Rir((int)'a', 47, 57, (int)'b');
/* returns 87 */
'a'is a JavaScriptstringbut a C#char