docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility module for finding products with minimum values based on various criteria in an e-commerce catalog.
[{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[{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[{name: "Television"}, {name: "PC"}, {name: "Monitor"}], returns the product with the shortest name {name: "PC"} @test[], returns undefined @test/**
* 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
};Provides utility functions for working with arrays and objects.