JSFiddle - React, Tailwind, and code Playground
JavaScript
fun = function(n) {
n = n + '';
if(n.substring(n.length - 1, n.length) == 'i') {
return 0 - parseInt(n.substring(0, n.length - 1));
}
return n+'i';
}
//This function is such that fun(fun(n)) = -n
//uncomment below line to try it out:
//alert(fun(fun(-565)))