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 :: heroku proxy cross origin 
Javascript :: get data firebase 
Javascript :: react catch error json message 
Javascript :: practice javascript 
Javascript :: javascript decrement 
Javascript :: ERROR TypeError: By.Subject is not a constructor 
Javascript :: remove elemtns from an array with splice 
Javascript :: js ternaire 
Javascript :: html to jsx 
Javascript :: esbuild 
Javascript :: datepicker auto select off 
Javascript :: how to link prototypes in js using call method 
Javascript :: Javascript basic arrow function 
Javascript :: find consecutive numbers in an array javascript 
Javascript :: nodejs ERR_CONNECTION_REFUSED 
Javascript :: send embed with webhook in JS 
Javascript :: how to set dynamic autocomplete with material ui 
Javascript :: ag grid angular examples 
Javascript :: jquery toggle visibility 
Javascript :: how to disable input in javascript 
Javascript :: clear ckeditor textarea jquery 
Javascript :: javascript filter array return index 
Javascript :: Error capturing image. ionic 
Javascript :: express req.body empty 
Javascript :: compare two dates in javascript 
Javascript :: hook use effect with hooks 
Javascript :: JSX element event listeners 
Javascript :: GoogleMap: center or defaultCenter property must be defined 
Javascript :: react final form 
Javascript :: Using An Array As A Parameter Of A Function 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =