Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
replace solution in Clear category for Beginning Zeros by Sim0000
import assert from "assert";
function beginningZeros(text: string): number {
return text.length - text.replace(/^0*/, '').length;
}
console.log('Example:');
console.log(beginningZeros('100'));
// These "asserts" are used for self-checking
assert.equal(beginningZeros('100'), 0);
assert.equal(beginningZeros('001'), 2);
assert.equal(beginningZeros('100100'), 0);
assert.equal(beginningZeros('001001'), 2);
assert.equal(beginningZeros('012345679'), 1);
assert.equal(beginningZeros('0000'), 4);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
April 24, 2020
Comments: