Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Beginning Zeros by vvm70
import assert from "assert";
var beginningZeros = text => text.match(/^0*/)[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!");
Oct. 20, 2020
Comments: