let solution = [];
let pocketStr = '10бун + 100коп';
solution = function (pocketStr) {
pocketStr = pocketStr.split(/бун/); //я не знаю регулярных выражений, знаю, что можно сделать проще
pocketStr = pocketStr.join('');
pocketStr = pocketStr.split('+');
pocketStr = pocketStr.join('');
pocketStr = pocketStr.split('коп');
pocketStr = pocketStr.join('');
pocketStr = pocketStr.split(/ +/);
let bun = pocketStr[0];
let kop = pocketStr[1];
if (kop >= 100) {
bun +=1;
kop = 0
}
pocketStr = bun + 'бун' + ' ' + kop + 'коп';
console.log(pocketStr);
return pocketStr;
}
console.log(solution);
console
function (pocketStr) { pocketStr = pocketStr.split(/бун/); pocketStr = pocketStr.join(''); pocketStr = pocketStr.split('+'); pocketStr = pocketStr.join(''); pocketStr = pocketStr.split('коп'); pocketStr = pocketStr.join(''); pocketStr = pocketStr.split(/ +/); let bun = pocketStr[0]; let kop = pocketStr[1]; if (kop >= 100) { bun += 1; kop = 0; } pocketStr = bun + 'бун' + ' ' + kop + 'коп'; console.log(pocketStr); return pocketStr; }