Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to make fake binary

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

Fake Binary

// 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
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to find date in a string js 
Javascript :: descending order in objects in js 
Javascript :: js date in two weeks 
Javascript :: how to set empty date in javascript 
Javascript :: using async function in useeffect 
Javascript :: rgb javascript 
Javascript :: switch alert 
Javascript :: for of loop in es6 
Javascript :: uncaught (in promise): both the table and dtoptions cannot be empty 
Javascript :: puppeteer headless 
Javascript :: Material-ui camera icon 
Javascript :: base64 to image nodejs 
Javascript :: check object is null empty or undefined 
Javascript :: enzyme-adapter-react-17 
Javascript :: create an element jquery 
Javascript :: how to show json data in javascript 
Javascript :: how to delete an element of an array in javascript 
Javascript :: slice method in js 
Javascript :: vue toggle boolean on click 
Javascript :: uncheck checkbox when another is checked javascript 
Javascript :: add toolbar button quill.js 
Javascript :: json minecraft 
Javascript :: js copy paragraph onclick 
Javascript :: get user country code javascript 
Javascript :: javascript count character in string 
Javascript :: express minify html 
Javascript :: round down the number javascript 
Javascript :: render XML in node 
Javascript :: npm react dropdown 
Javascript :: js indexof second occurrence 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =