Web Development
Number Guessing Game
Overview
Developed as a collaborative project among a team of 4 within the Mayerfeld Practicum Program, the Number Guessing Game is a browser-based, console-driven interactive application where the player competes against a simulated AI to guess a hidden number between 1 and 100 within a maximum limit of 10 attempts.
The main objective of this assignment was to construct a robust, logic-driven game engine using Vanilla JavaScript. Designed around interactive terminal execution, the project emphasizes foundational programming concepts—including dynamic random number generation, input validation loops, stateful attempt tracking, conditional feedback evaluation, and an integrated bonus scoring mechanism based on speed and efficiency.
The Challenge
Building an interactive console game requires creating a bulletproof control flow that gracefully guides the player through each turn while defending against invalid inputs and logical edge cases.
Key technical challenges included:
- Random Target Generation: Engineering a precise mathematical function (generateRandomNumber) to produce unpredictable integer values between 1 and 100 on every session.
- Defensive Input Handling: Designing an isolated input function (getPlayerGuess) that prompts the user, converts raw inputs to integers, detects non-numeric entries or cancellations, and continuously reprompts until a valid guess is provided.
- Game State & Loop Control: Managing a turn-based loop (game) that executes up to 10 valid attempts, accurately evaluating guess states ("too high", "too low", or "correct") while enforcing game-over boundaries.
- Bonus Scoring Architecture: Formulating a mathematical scoring algorithm that evaluates player performance and awards dynamic point totals based on the minimum number of attempts utilized.
- Team Integration & Collaboration: Coordinating code across 4 developers to ensure consistent coding standards, clean syntax, and seamless function interoperability without console runtime exceptions.
Our Approach
Working within a 4-person team framework, we divided the application into modular, single-responsibility JavaScript functions, ensuring defensive programming and clean execution at every step:
- Target Generation Engine (generateRandomNumber): Utilized Math.random() and Math.floor() to generate a uniform integer range from 1 to 100.
- Robust Input Guard (getPlayerGuess): Constructed a validation loop leveraging parseInt() and isNaN() checks. If a user inputs text, leaves the input blank, or submits out-of-bounds values, the function displays an alert and reprompts until valid integer data is received.
- Comparison Evaluator (checkGuess): Implemented a pure helper function that compares the player's guess against the target integer and returns definitive output strings to drive player feedback.
Main Game Controller (game): Integrated the overarching game loop managing the session state:
- Initialized an attempt counter capped at 10 turns.
- Logged real-time feedback after every guess, notifying the player if their attempt was too high or too low.
- Incorporated a dynamic Bonus Scoring System that calculates final points proportional to remaining attempts upon a correct guess.
- Printed clear win/loss messages and total attempts used directly to the developer console.
- Collaborative Code Review: Conducted joint debugging sessions to eliminate edge-case errors, streamline console output formatting, and maintain ES6 standard compliance.
Project Gallery
Results
Developed successfully under the Mayerfeld Practicum Program framework, the project delivered an engaging, error-proof console mini-game that met all assignment objectives while highlighting strong Vanilla JavaScript fundamentals:
- Flawless Game Mechanics: Executed smooth 10-attempt game sessions with accurate target evaluation, attempt limits, and instant conditional feedback.
- Zero-Error Input Resilience: Handled invalid inputs, letters, and empty prompt entries seamlessly without crashing or generating unhandled console exceptions.
- Gamified Performance System: Successfully integrated a bonus scoring model that added replayability and incentivized strategic guessing.
- Effective Team Collaboration: Maintained a unified, clean, and well-commented codebase through structured peer review and collaborative problem-solving among all 4 members.
YEAR
2026
SERVICES
Web Design & Development
Interactive Experience
Collaborative Software Engineering
TOOLS & TECHNOLOGY
JavaScript
HTML5
VS Code
Git
GitHub
Chrome DevTools
Console API
TAGS
Web Development
Team Collaboration
Game Mechanics
Functional Programing
Algorithmic Logic
Console Game
JavaScript
Interested in a similar project?
