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

duplicate method #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions test/js-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,26 @@ function calculateTotalWithServiceFee(items, serviceFeeRate) {
return totalPrice;
}


// Function 4: Calculate the total price of items with a non refundable fee
function calculateTotalWithNonRefundableFee(items, serviceFeeRate) {
let totalPrice = 0;
for (let i = 0; i < items.length; i++) {
totalPrice += items[i].price * items[i].quantity;
}
let serviceFee = totalPrice * serviceFeeRate;
totalPrice += serviceFee;

console.log("Items in cart:");
for (let i = 0; i < items.length; i++) {
console.log(`Item: ${items[i].name}, Quantity: ${items[i].quantity}, Price: $${items[i].price}`);
}
console.log(`Non-refundable Fee: $${serviceFee.toFixed(2)}`);
console.log(`Total Price with Service Fee: $${totalPrice.toFixed(2)}`);

return totalPrice;
}

// Function 1: Check if a number is even
function isEven(number) {
return number % 2 === 0;
Expand Down