Created
June 3, 2020 19:36
-
-
Save ViniciusFXavier/17f548ba7f16896945708ddc1b0ec743 to your computer and use it in GitHub Desktop.
IP Address Generator/Validator
This file contains 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
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() |
This file contains 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
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