BeginnerCoder

Lesson 16 — Version compare

Which version is newer?

Comparing versions as text is a trap: "1.10.0" < "1.9.0" is true for strings, because "1" comes before "9". You must split into numbers and compare part by part — major first, then minor, then patch. The first part that differs decides.

"1.10.0".split(".").map(Number)   // [1, 10, 0]

Why it matters: auto-updaters and deploy tools that get this wrong install the older version.

Want it another way?
Task

Finish the loop in newer(): return true as soon as a part of b is bigger than the same part of a, false as soon as it is smaller.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with DevOps Foundations

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.