JSFiddle - React, Tailwind, and code Playground
by lavisha99
HTML
let product=
JavaScript
let product = [{
name: 'pullover',
price: 99.99,
sizeArray: [{
size: 's',
quantity: 500000
}, {
size: 'l',
quantity: 0
}]
},
{
name: 'skirt',
price: 99.99,
sizeArray: [{
size: 's',
quantity: 1
}, {
size: 'l',
quantity: 0
}]
},
{
name: 'top',
price: 99.99,
sizeArray: [{
size: 's',
quantity: 0
}, {
size: 'l',
quantity: 0
}]
},
{
name: 'jeans',
price: 99.99,
sizeArray: [{
size: 's',
quantity: 0
}, {
size: 'l',
quantity: 0
}]
},
{
name: 'dress',
price: 99.99,
sizeArray: [{
size: 's',
quantity: 0
}, {
size: 'l',
quantity: 0
}]
}
];
console.log(product);
let product1Price = product[0].price * (product[0].sizeArray[0].quantity + product[0].sizeArray[1].quantity);
let product2Price product[1].price * (product[1].sizeArray[0].quantity + product[1].sizeArray[1].quantity);
let total = (product[0].price * (product[0].sizeArray[0].quantity + product[0].sizeArray[1].quantity)) + (product[1].price * (product[1].sizeArray[0].quantity + product[1].sizeArray[1].quantity)) + (product[2].price * (product[2].sizeArray[0].quantity + product[2].sizeArray[1].quantity)) + (product[3].price * (product[0].sizeArray[0].quantity + product[0].sizeArray[1].quantity)) + (product[4].price * (product[0].sizeArray[0].quantity + product[0].sizeArray[1].quantity));
console.log(total);
if (total < 10000) {
console.log('processed');
} else if (total <= 50000) {
console.log('junior manager approval needed');
} else if (total >= 50000) {
console.log('senior manager approval needed');
}
function OrderProcessed(thisorder) {
console.log('the total is' +total);
}
console.log(thisorder);
let anotherOrder = [{
name: 'shirt',
price: 99.99,
sizeArray: [{
size: 's',
quantity: 50
}, {
size: 'l',
quantity: 0
}]
}]
let anotherTotal=...