let value=121;
const reverse= function(value) {
//convert the value into string and then split then reverse then join the string
let revVal=value.toString().split("").reverse().join("");
//convert the string into number using parseInt
revVal=parseInt(revVal)
//use math.abs function for taking absolute value then multiply with sign of original value
revVal=Math.abs(revVal)*Math.sign(value)
if (revVal>= 2**31|| revVal < 2**31*(-1)) {
return 0;
}
else{
return revVal
}
};
reverse(value);
Wonderful
ReplyDelete