or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-1/

Product Price Finder

A utility module for finding products with minimum values based on various criteria in an e-commerce catalog.

Capabilities

Find cheapest product

  • Given an array of products [{name: "Laptop", price: 999}, {name: "Mouse", price: 25}, {name: "Keyboard", price: 75}], returns the product object with the lowest price {name: "Mouse", price: 25} @test

Find product with minimum rating

  • Given an array of products [{name: "ProductA", rating: 4.5}, {name: "ProductB", rating: 3.2}, {name: "ProductC", rating: 4.8}], returns the product with the lowest rating {name: "ProductB", rating: 3.2} @test

Find product with shortest name

  • Given an array of products [{name: "Television"}, {name: "PC"}, {name: "Monitor"}], returns the product with the shortest name {name: "PC"} @test

Handle empty arrays

  • Given an empty array [], returns undefined @test

Implementation

@generates

API

/**
 * Finds the product with the minimum price from an array of products.
 *
 * @param {Array<Object>} products - Array of product objects with price property
 * @returns {Object|undefined} The product with the minimum price, or undefined if array is empty
 */
function findCheapestProduct(products) {
  // IMPLEMENTATION HERE
}

/**
 * Finds the product with the minimum rating from an array of products.
 *
 * @param {Array<Object>} products - Array of product objects with rating property
 * @returns {Object|undefined} The product with the minimum rating, or undefined if array is empty
 */
function findMinRatingProduct(products) {
  // IMPLEMENTATION HERE
}

/**
 * Finds the product with the shortest name from an array of products.
 *
 * @param {Array<Object>} products - Array of product objects with name property
 * @returns {Object|undefined} The product with the shortest name, or undefined if array is empty
 */
function findShortestNameProduct(products) {
  // IMPLEMENTATION HERE
}

module.exports = {
  findCheapestProduct,
  findMinRatingProduct,
  findShortestNameProduct
};

Dependencies { .dependencies }

lodash { .dependency }

Provides utility functions for working with arrays and objects.