let getSuccessRate = (statistic, patern) => `${100 * [...statistic].reduce((a, c) => a+= (c === patern) , 0) / statistic.length | 0}%`; console.log(getSuccessRate('001101', '1'))