Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Avoiding using if-else statements
function _ifElseFn(condition, cb, cb2){
var result = {true:cb,false:cb2};
return result[condition]();
function sayYourCarIsOld(){
console.log('your car is old');
function sayYourCarIsNew(){
console.log('your car is new');
var newCar = false;
newCar = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment