function solution(code) {
let mode = 0
const ret = [...code].filter((str, idx)=>{
if (str === '1') {
mode = mode === 0 ? 1 : 0
return false;
}
if (mode === 1) {
return idx % 2 === 1
} else {
return idx % 2 === 0
}
}).join('');
return ret.length !== 0 ? ret : "EMPTY";
}
function solution(code) {
let answer = '';
let mode = 0;
for (let i = 0; i < code.length; i += 1) {
if (Number(code[i]) === 1) {
mode = mode === 1 ? 0 : 1;
}
if (Number(code[i]) !== 1 && i % 2 === mode) {
answer += code[i];
}
}
return answer.length > 0 ? answer : 'EMPTY';
}