or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

Browser Compatibility Checker

Build a browser compatibility checking utility that determines whether a user's browser meets version requirements for a web application.

Requirements

Create a module that exports a function checkBrowserCompatibility(userAgent, requirements) that:

  1. Accepts a user agent string as the first parameter
  2. Accepts a requirements object as the second parameter with the following structure:
    • minimum: The minimum browser version required (string with operator, e.g., ">=70")
    • maximum: Optional maximum browser version allowed (string with operator, e.g., "<100")
    • recommended: Optional recommended browser version (string with operator, e.g., ">=85")
  3. Returns an object with:
    • compatible: boolean indicating if the browser meets minimum requirements
    • recommended: boolean indicating if the browser meets recommended requirements (or true if no recommendation specified)
    • browserInfo: object containing the detected browser name and version
    • message: string describing the compatibility status

Behavior

  • If the browser version cannot be detected, return compatible: false with an appropriate message
  • The browser is compatible if it meets the minimum version requirement AND does not exceed the maximum version (if specified)
  • The browser is recommended if it meets the recommended version requirement
  • Generate descriptive messages based on compatibility status

Test Cases

  • Given a Chrome 91 user agent and minimum version ">=70", the function returns compatible: true @test
  • Given a Chrome 65 user agent and minimum version ">=70", the function returns compatible: false @test
  • Given a Chrome 91 user agent, minimum ">=70", and maximum "<100", the function returns compatible: true @test
  • Given a Chrome 105 user agent, minimum ">=70", and maximum "<100", the function returns compatible: false (exceeds maximum) @test
  • Given a Chrome 91 user agent, minimum ">=70", and recommended ">=85", the function returns both compatible: true and recommended: true @test

Implementation

@generates

API

/**
 * Check if a browser meets version requirements
 * @param {string} userAgent - The browser's user agent string
 * @param {Object} requirements - Version requirements
 * @param {string} requirements.minimum - Minimum version required (with operator, e.g., ">=70")
 * @param {string} [requirements.maximum] - Optional maximum version allowed (with operator, e.g., "<100")
 * @param {string} [requirements.recommended] - Optional recommended version (with operator, e.g., ">=85")
 * @returns {Object} Compatibility result with compatible, recommended, browserInfo, and message properties
 */
function checkBrowserCompatibility(userAgent, requirements) {
  // IMPLEMENTATION HERE
}

module.exports = { checkBrowserCompatibility };

Dependencies { .dependencies }

bowser { .dependency }

Provides browser detection and version comparison capabilities.