Skip to content

Instantly share code, notes, and snippets.

@shcyiza
Last active May 26, 2022 08:20
Show Gist options
  • Save shcyiza/33c3625c926c7f46053fbb4e896ab79a to your computer and use it in GitHub Desktop.
Save shcyiza/33c3625c926c7f46053fbb4e896ab79a to your computer and use it in GitHub Desktop.
// respond variable was given before
function displayContent(attrName, lang) {
const valid_attrs = ["title", "abstract"]
const valid_langs = ["en", "nl", "fr"]
// validate attrName and lang before accessing property
if (valid_attrs.includes(attrName) && valid_langs.includes(lang)) return respond.data[attrName][lang]
return null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment