Given a string of digits, you should replace any digit below 5 with '0' and any digit 5 and above with '1'. Return the resulting string.
function fakeBin(x){
let xList = x.split("");
let sol = [];
for (let i=0; i < x.length; i++) {
if (Number(xList[i]) < 5) {
sol.push("0");
}
else {
sol.push("1");
}
}
return sol.join("")
}
function fakeBin(x) {
return x.split('').map(n => n < 5 ? 0 : 1).join('');
}