I'm trying to make an art quote calculator and am having trouble with the following code. I want the calculateQuote function to traverse through the costs object using the value of different select elements in order to find the right price and then display that price. However, I'm running into an error somewhere in the submit.onclick portion I believe. When I run the code, at that step, nothing gets populated onto the page.
const costs = {
"painting": {
"simple": {
"_10x10": "25",
"_11x14": "55",
"_16x20": "75",
"_18x24": "100"},
"complex": {
"_10x10": "55",
"_11x14": "75",
"_16x20": "100",
"_18x24": "150-250"}
},
"pencil": {
"simple": {
"_11x14": "150"},
"complex": {
"_11x14": "150"}
},
"mural": {
"simple": {
"_3x5": "200-300",
"_8x12": "750",
"_10x12": "950",
"_8x24": "1,500"},
"complex": {
"_3x5": "500",
"_8x12": "1,150",
"_10x12": "1,400",
"_8x24": "2,300"}
}
}
function calculateQuote(){
if(typeElement.value === "painting"){
const finalquote = costs.typeValue.complexityValue.paintingSizeValue;
} else if(typeElement.value === "pencil"){
const finalquote = costs.typeValue.complexityValue.pencilSizeValue;
} else {
const finalquote = costs.typeValue.complexityValue.muralSizeValue;
}
return finalquote;
}
submit.onclick = function(){
hideDiv(complexityElement);
hideDiv(complexityLabelElement);
hideDiv(submit);
let clientQuote = document.createElement('p');
clientQuote.innerHTML = calculateQuote();
quoteDiv.appendChild(clientQuote);
quoteDiv.style.display = "block";
}