Building a Voter's Eligibility Checker

Few days ago, I officially started my journey into software development. As a Computer Science student, I know that theory is important, but building actual projects is where the real learning happens. My very first task? Creating a Voting Eligibility Checker.
The Goal
I wanted to write a script that takes a person's age and determines if they are old enough to vote. In Nigeria, the voting age is 18, so the logic was simple but fundamental.
The Code
Here is the script I wrote and pushed to my GitHub ππ½ππ½ππ½
' ' ' javascript
// Start of code
let ageInput = prompt("Please enter your age to check your voting eligibility:");
let userAge = Number(ageInput);
if (isNaN(userAge)) {
console.log("Error: Please enter a valid number for your age. ");
} else if (userAge >= 18) {
console.log("You are " + userAge + " years old. You're eligible to vote! β ");
} else {
console.log("You are " + userAge + " years old. You aren't eligible to vote yet. β");
}
// End of code
' ' '
What Learned:
Variables: How to store data (the age).
Conditional Logic: Using if/else statements to make the computer "decide" based on a condition.
The Console: How to output results to see if my logic worked.
Final Thoughts
Itβs a small start, but it felt great to see the computer respond to my logic. This project taught me that even a few lines of code can solve a real world π question. Next, I'll be moving on to more complex tasks like loops and arrays.
Challenge:
I want to make this script more better and advanced. Can you modify this code to tell the user exactly how many years they need to wait if they aren't 18 yet? Drop you Solution in the comments below. Let's learn from each other! Thanks ππ½!!

