Skip to content

Instantly share code, notes, and snippets.

@neilrackett
Created August 9, 2017 16:03
Show Gist options
  • Save neilrackett/2c20beaf872642a150c0225ccf2e4873 to your computer and use it in GitHub Desktop.
Save neilrackett/2c20beaf872642a150c0225ccf2e4873 to your computer and use it in GitHub Desktop.
Convert and filter a comma delimited string into an Array of valid ID numbers
// Converts and filters a comma delimited string into an Array of valid database ID numbers, e.g. ",x,1,,0,~,4,5,7" => "1,4,5,7"
let ids = str.split(',').map(keywordId => ~~keywordId).filter(keywordId => keywordId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment