I have a problem to solve involving default parameters and object destructuring. I have an object 'product' with this shape:
{
name: "Slip Dress",
priceInCents: 8800,
availableSizes: [ 0, 2, 4, 6, 10, 12, 16 ]
}
Here is my code so far, but I am receiving an error that 'availableSizes' is not iterable. Can someone help me correct this code?
I have tried adjusting the default parameters in my function and I have moved my return statements to no avail.
function checkIfSizeIsAvailable(product = {availableSizes:[]}, size = 0) {
// let availableSizes = product;
let foundSize = "";
for (let sizeCheck of product.availableSizes) {
if (sizeCheck === size) {
foundSize = size;
}
}
if (foundSize === ""){
return false;
} else {
return true;
}
//for (let i = 0; i < sizes.length; i++) {
// return false;
}
productwhich doesn't haveavailableSizes