docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a browser compatibility checking system that determines whether a given browser meets specified version requirements.
Create a module that exports a function checkBrowserCompatibility(userAgent, requirements) which:
compatible: boolean indicating if the browser meets all requirementsbrowserInfo: object with browser name and versionfailedChecks: array of requirement keys that failed (empty if all pass)The requirements object can contain any of these properties:
minVersion: Browser version must be greater than or equal to this valuemaxVersion: Browser version must be less than or equal to this valueexactVersion: Browser version must exactly match this valuenotVersion: Browser version must not match this valueThe system should:
Provides browser detection and version comparison capabilities.
Input:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"{ minVersion: "100.0.0" }Expected Output:
{
compatible: true,
browserInfo: { name: "Chrome", version: "120.0.0.0" },
failedChecks: []
}Input:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"{ minVersion: "100.0.0" }Expected Output:
{
compatible: false,
browserInfo: { name: "Chrome", version: "95.0.4638.69" },
failedChecks: ["minVersion"]
}Input:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15"{ minVersion: "14.0", maxVersion: "16.0" }Expected Output:
{
compatible: true,
browserInfo: { name: "Safari", version: "15.6.1" },
failedChecks: []
}Input:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0"{ exactVersion: "115.0" }Expected Output:
{
compatible: true,
browserInfo: { name: "Firefox", version: "115.0" },
failedChecks: []
}src/compatibility-checker.js: Main compatibility checking logicsrc/compatibility-checker.test.js: Test file containing the test cases above