Skip to content

Instantly share code, notes, and snippets.

@sreubenstone
Created January 29, 2019 19:43
Show Gist options
  • Save sreubenstone/b715ccfd96cb637af4258cb1a72f805a to your computer and use it in GitHub Desktop.
Save sreubenstone/b715ccfd96cb637af4258cb1a72f805a to your computer and use it in GitHub Desktop.
regex-sr
const string = '4%4%15%30%33%'
const fixed = string.replace(/%/g, ' ');
console.log(fixed)
const array = fixed.split(' ')
console.log(array)
array.forEach(element => {
const integer = parseInt(element, 10);
if (integer % 4 === 0) { console.log(`${integer} divisible by four`) }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment