“Binario falso” Código de respuesta

Cómo hacer binario falso

function fakeBin(x) {
  return x.replace(/\d/g, d => d < 5 ? 0 : 1);
}
// for code wars lol
TechWhizKid

Binario falso

// 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.
// Note: input will never be an empty string

function fakeBin(x){
  let binary = ''
  x.split('').forEach(letter => Number(letter) < 5 ? binary += 0: binary += 1)
  return binary
}

// With love @kouqhar
kouqhar

Respuestas similares a “Binario falso”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código