Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

JavaScript foundations: Object shorthand & spread Instructions To complete this Practice problem, you will update the existing functions in src/solution

Sociology Nov 24, 2021

JavaScript foundations: Object shorthand & spread

Instructions

To complete this Practice problem, you will update the existing functions in src/solution.js to use new syntax you have learned. Use object shorthand and the spread operator whenever possible.

/*

Modify each function below to continue working with the suggested syntax.

When a function's parameters reference `product`, it is referring to an object. Each object has the following shape:

{

name: "Washed Black Denim Overalls",

priceInCents: 12000,

availableSizes: [ 28, 30, 32, 36 ]

}

*/

// `salesTax` is a decimal number, like 0.065

function createSalesProduct(product, salesTax) {

return {

name: product.name,

availableSizes: product.availableSizes,

salesTax: 0.065,

priceInCents: product.priceInCents * (1 + salesTax),

};

}

function joinSizes(productA, productB) {

const result = ...productA.availableSizes, ...productB.availableSizes;

}

return result;

}

Expert Solution

Please view explanation and answer below.

function joinSizes(productA, productB) {

 

const result = [...productA.availableSizes,...productB.availableSizes];

 

return result;

 

}

 

function createSalesProduct(product, salesTax) {

 

 

let {name, availableSizes} = product;

 

 

return {

 

name: name,

 

availableSizes: availableSizes,

 

salesTax: salesTax,

 

priceInCents: product.priceInCents * (1 + salesTax),

 

};

 

}

Archived Solution
Unlocked Solution

You have full access to this solution. To save a copy with all formatting and attachments, use the button below.

Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get 100% fresh solution
Get Custom Quote
Secure Payment