or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-9/

OS Information Reporter

Build a utility that analyzes user agent strings and generates formatted reports about operating system information, with a focus on providing human-readable version names.

Requirements

Create a module that provides OS detection and reporting functionality:

Core Functionality

  1. Parse User Agent Strings: Accept user agent strings as input and extract OS information
  2. Format OS Information: Generate a formatted summary that includes:
    • Operating system name
    • Version number
    • Human-readable version name (when available)
  3. Handle Multiple User Agents: Process arrays of user agent strings and return consolidated reports

Output Format

The OS report should be a plain text string with the following format for each user agent:

OS: [name] | Version: [version] | Name: [versionName or "N/A"]

If version name is not available, display "N/A".

Edge Cases

  • Handle user agents where OS information is incomplete or missing
  • Return appropriate defaults when version names are unavailable
  • Support both modern and legacy user agent strings

Test Cases

  • It returns formatted OS report for Windows 10 user agent including name, version, and version name @test
  • It returns formatted OS report for macOS Big Sur user agent with version name "Big Sur" @test
  • It returns formatted OS report for Android Pie user agent with version name "Pie" @test
  • It processes multiple user agents and returns a multi-line report @test

Implementation

@generates

API

/**
 * Analyzes a user agent string and returns formatted OS information.
 *
 * @param {string} userAgent - The user agent string to analyze
 * @returns {string} Formatted OS information string
 */
function getOSReport(userAgent) {
  // IMPLEMENTATION HERE
}

/**
 * Analyzes multiple user agent strings and returns a consolidated report.
 *
 * @param {string[]} userAgents - Array of user agent strings to analyze
 * @returns {string} Multi-line report with one line per user agent
 */
function getBatchOSReport(userAgents) {
  // IMPLEMENTATION HERE
}

module.exports = {
  getOSReport,
  getBatchOSReport
};

Dependencies { .dependencies }

bowser { .dependency }

Provides user agent parsing and OS detection capabilities.