function getSuccessRate(statistic) { return statistic.match(/1/g).length / statistic.length } console.log(getSuccessRate('001101'))