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.
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.
A quick 3-question quiz on this lesson — instant feedback.
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.
Project-based DevOps Foundations courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for DevOps Foundations books — check the publication year so the examples match current versions.
Search Amazon →