Back to all solutions
#2710 - Remove Trailing Zeros From a String
Problem Description
Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.
Solution
/**
* @param {string} num
* @return {string}
*/
var removeTrailingZeros = function(num) {
return num.replace(/0+$/g, '');
};