FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Coding Challenge Practice - Question 119
How-ToMachine Learning

Coding Challenge Practice - Question 119

via Dev.to BeginnersBukunmi Odugbesan1d ago

The task is to implement a function that validates IPv4 and IPv6 IP addresses. The boilerplate code function isValidIP(str) { // your code here } A valid IPv4 address should be in 4 parts, separated by ".", and should contain digits between 0 and 255, with no number having a leading zero. Create a function to validate those parameters function isValidIPv4(ip) { } Each part should be separated by "." const parts = ip.split("."); There must be exactly 4 parts if(parts.length !== 4) return false; If the number is less than zero or greater than 255, it is not a valid IPv4 address. The number should also not have a leading 0. for (const part of parts) { if (!/^\d+$/.test(part)) return false; if (part.length > 1 && part[0] === '0') return false; const num = Number(part); if (num < 0 || num > 255) return false; } return true; } The complete function to validate an IPv4 address function isValidIPv4(ip) { const parts = ip.split('.'); if (parts.length !== 4) return false; for (const part of part

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
3 views

Related Articles

A gentle introduction to machine code, compilers, and LLVM
How-To

A gentle introduction to machine code, compilers, and LLVM

Medium Programming • 12h ago

Sony Promo Codes and Discounts: 45% Off
How-To

Sony Promo Codes and Discounts: 45% Off

Wired • 12h ago

I Wanted Extra Income — 7 Things I Learned the Hard Way
How-To

I Wanted Extra Income — 7 Things I Learned the Hard Way

Medium Programming • 14h ago

How to clear your Google Search cache on Android (and why it's a must for me)
How-To

How to clear your Google Search cache on Android (and why it's a must for me)

ZDNet • 16h ago

15+ best Alexa commands to make your home work smarter (Prime not required)
How-To

15+ best Alexa commands to make your home work smarter (Prime not required)

ZDNet • 17h ago

Discover More Articles