Created
July 8, 2017 23:24
-
-
Save Woodsphreaker/6c9f03051b316839680280c15cc04aa2 to your computer and use it in GitHub Desktop.
Replace Switch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getService = (type) => { | |
const pres = () => "ppt" | |
const doc = () => "doc" | |
const sheet = () => "sheet" | |
const text = () => "text" | |
const pdf = () => "pdf" | |
const other = () => "default" | |
const service = { | |
xls: sheet, | |
xlsx: sheet, | |
doc: doc, | |
docx: doc, | |
ppt: pres, | |
pptx: pres, | |
txt: text, | |
pdf: pdf, | |
other: other | |
} | |
return (service[type] || service["other"])() | |
} | |
console.log(getService("docx")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment