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

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

Subject:Computer SciencePrice:19.89 Bought3

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;

}

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

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),

 

};

 

}