Hello, does anyone know how to solve it? I tried it with a thousand formulas and nothing
> function fakeBinary2(string) {
The function called 'fakeBinary' receives as an argument a string with numbers and must return a string where numbers less than 5 are replaced with '0' and numbers equal to or greater than 5 with '1'
// Por ej:
// fakeBinary2('5627') devuelve "1101"
// fakeBinary("729") devuelve "101"
// Tu código aca:
} I don't know how to deal with the statement I think, I tried making an array of "string" but each element remains as a string so I don't know how to indicate "if less than 5 replace with 1" and so on. I hope it is understood
function fakeBinary2(string) {
string = string.split(",");
for (let i=0; i< string,length; i++ ){
if (string[i] == "2"||"3"||"4"){
string.replace(i, "0")
} else if (string[i] == "5"||"6"||"7"||"8"||"9"){
string.replace(i, "1")}
} return string;
}