π
π»ββοΈ λμ 첫 λ²μ§Έ νμ΄
function evenBinary(n) {
const splittedN = n.split(" ");
const sortedEvenArr = splittedN.filter((num) => num[2] === `0`).sort();
let evenArrIdx = 0;
for (let i = 0; i < splittedN.length; i++) {
if (splittedN[i][2] === `0`) {
splittedN.splice(
splittedN.indexOf(splittedN[i]),
1,
sortedEvenArr[evenArrIdx]
);
evenArrIdx++;
}
}
return splittedN;
}
ππ»ββοΈ λμ λ λ²μ§Έ νμ΄
function evenBinary(n) {
const splittedN = n.split(" ");
const sortedEvenArr = splittedN.filter((num) => num[2] === `0`).sort();
let evenArrIdx = 0;
for (let i = 0; i < splittedN.length; i++) {
if (splittedN[i][2] === `0`) {
splittedN.splice(i, 1, sortedEvenArr[evenArrIdx]);
evenArrIdx++;
}
}
return splittedN;
}