Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Practice - Adrian Gonzalez #1

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
* Use Composer to rename references from 'multiplyComposerNumbers' to 'multiply'
* across this file AND the usage files (composerUsageOne.js, composerUsageTwo.js).
*/
function multiplyComposerNumbers(a, b) {
return a * b;
}

module.exports = { multiplyComposerNumbers };

function multiply(a, b) {
return a * b;
}

module.exports = { multiply };
4 changes: 2 additions & 2 deletions src/composerUsageOne.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* This file references the function in composer.js as 'multiplyComposerNumbers'.
* We'll need to rename it if we want everything to match the test's expectation of 'multiply'.
*/
const { multiplyComposerNumbers } = require('./composer');
const { multiply } = require("./composer");

function calculateRectangles(rectangles) {
// Each rectangle has { width, height }
return rectangles.map(({ width, height }) => multiplyComposerNumbers(width, height));
return rectangles.map(({ width, height }) => multiply(width, height));
}

module.exports = calculateRectangles;
4 changes: 2 additions & 2 deletions src/composerUsageTwo.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Also references the same function from composer.js.
*/
const { multiplyComposerNumbers } = require('./composer');
const { multiply } = require("./composer");

function calculateVolumes(cubes) {
// Each cube has { width, height, depth }
// We'll multiply them to get volume
return cubes.map(({ width, height, depth }) =>
multiplyComposerNumbers(multiplyComposerNumbers(width, height), depth)
multiply(multiply(width, height), depth)
);
}

Expand Down
16 changes: 11 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// App configuration constants
const APP_CONFIG = {
name: "cursor-practice",
version: "1.0.0",
};

/**
* Simple function that returns basic info about the app.
* Returns basic information about the application.
* @returns {Object} Object containing app name and version
* @returns {string} returns.name - The name of the application
* @returns {string} returns.version - The current version number
*/
function getAppInfo() {
return {
name: "cursor-practice",
version: "1.0.0",
};
return { ...APP_CONFIG };
}

module.exports = getAppInfo;
28 changes: 19 additions & 9 deletions src/shippingCalculator.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
/**
* A function that *incorrectly* calculates shipping.
* The test expects a specific formula, but we are returning a hard-coded value.
* Use Cursor's Inline Edit to fix it, so the test will pass.
* A function that calculates shipping based on weight and region.
* Currently only implements base formula as region-specific pricing
* is not yet specified in tests.
*/
function calculateShipping(weight, region) {
// Currently always returns 10, which is WRONG
return 10;
}

module.exports = calculateShipping;

// Base shipping cost for all regions
const baseCost = 5;
const costPerWeight = 2;

// Future enhancement: Add region-specific multipliers or rules here
// Example:
// const regionMultipliers = {
// 'US': 1.0,
// 'EU': 1.2,
// 'ASIA': 1.5
// };

return baseCost + weight * costPerWeight;
}

module.exports = calculateShipping;