What’s the best way to do this other than many if statement if i’m going to compute stuff added to a cart or something
Form
acidBody: false
acidGlass: false
asphaltRemoval: false
ceilingDetail: false
ceramicBooster: false
ceramicCoating: false
clayBar: false
engineDetail: false
exteriorDetailing2: false
exteriorDetailing3: false
fullAcidCoating: false
fullDetail: false
glassCeramic: false
glassDetail: false
handWax: false
id: 1
interiorDetailing: false
machineWax: false
premiumWash: false
seatCleaning: true
size: "medium"
wax: false
wheelDetail: true
Here’s the value of what I’ll get if the form been submitted
Here’s where I’ll compare them so I can get the prices (these are the data that I will get from db)
{
name : "small",
price : 150
},
{
name : "medium",
price : 180
},
{
name : "large",
price : 200
},
{
name : "xl",
price : 220
},{
name : "motor",
price : 100
}
//and so on
I don’t want to know do something like
if form.value.size == ‘small’ then price = 150 and confirm all of that
is there an easy way to do this?
I tried looping but can’t get a unique comparison to determine the price of each item
MTL Auto Corp is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1