Skip to content

Instantly share code, notes, and snippets.

@ViniciusFXavier
Created June 3, 2020 19:36
Show Gist options
  • Save ViniciusFXavier/17f548ba7f16896945708ddc1b0ec743 to your computer and use it in GitHub Desktop.
Save ViniciusFXavier/17f548ba7f16896945708ddc1b0ec743 to your computer and use it in GitHub Desktop.
IP Address Generator/Validator
function run() {
const listIp = []
for (let index = 0; index < 1000; index++) {
const ip = (Math.floor(Math.random() * 255) + 1)+"."+(Math.floor(Math.random() * 255))+"."+(Math.floor(Math.random() * 255))+"."+(Math.floor(Math.random() * 255));
listIp.push(ip);
}
console.log('listIp: ', JSON.stringify(listIp))
}
run()
function isIpAddress(ipAddress) {
return /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/i.test(ipAddress);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment