Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

functional not if then else

//remove if then else...

OBJECT  MAPPER
const colors = { red: true, blue: true, 'default': false, }; 		//An object specifying the results
const colorMapper = color => colors[color] || colors['default'];    // A mapping function
const color = colorMapper(item.color);
 
PREVIOUS NEXT
Tagged: #functional
ADD COMMENT
Topic
Name
5+3 =