JavaScript错误未捕获类型错误:无法读取属性';0';未定义的

JavaScript错误未捕获类型错误:无法读取属性';0';未定义的,javascript,Javascript,我不能纠正这个错误,你能帮忙吗?在代码的第65行中添加else后出现错误。buttins停止添加值。从昨天开始,我花了几个小时试图修好它,但没有任何效果。我对开始出现问题的代码部分进行了注释。你能向我建议什么样的解决方案?我确信没有任何syntex错误 enter code here const DATA = { whichSite: ['landing', 'multiPage', 'onlineStore'], price: [4000, 8000, 26000], desktopTempl

我不能纠正这个错误,你能帮忙吗?在代码的第65行中添加else后出现错误。buttins停止添加值。从昨天开始,我花了几个小时试图修好它,但没有任何效果。我对开始出现问题的代码部分进行了注释。你能向我建议什么样的解决方案?我确信没有任何syntex错误

enter code here const DATA = {
whichSite: ['landing', 'multiPage', 'onlineStore'],
price: [4000, 8000, 26000],
desktopTemplates: [50, 40, 30],
adapt: 20,
mobileTemplates: 15,
editable: 10,
metrikaYandex: [500, 1000, 2000],
analyticsGoogle: [850, 1350, 3000],
sendorder: 500,
deadlineDay: [ [2, 7], [3, 10], [7, 14]],
deadlinePercent: [20, 17, 15]
}

const startButton = document.querySelector('.start-button'),
  firstScreen = document.querySelector('.first-screen'),
  mainForm = document.querySelector('.main-form'),
  formCalculate = document.querySelector('.form-calculate'),
  endButton = document.querySelector('.end-button'),
  total = document.querySelector('.total'),
  fastRange = document.querySelector('.fast-range'),
  totalPriceSum = document.querySelector('.total_price__sum');

function showElem(elem){
elem.style.display = 'block';
}

function hideElem(elem){
elem.style.display = 'none';
 }

 function priceCalculation(elem){
let result = 0,
    index = 0,
    options = [];

if(elem.name === 'whichSite'){
  for (const item of formCalculate.elements) {
      if (item.type === 'checkbox') {
          item.checked = false;
      }
  }
  hideElem(fastRange);
  } 

  for (const item of formCalculate.elements) {
  if( item.name === 'whichSite' && item.checked){
      index = DATA.whichSite.indexOf(item.value);
  } 
  if (item.classList.contains('calc-handler') && item.checked){
      options.push(item.value);
  }
}

options.forEach(function(key) {
  if(typeof(DATA[key]) === 'number') {
      if (key === 'sendOrder') {
          result += DATA[key]
      }  else {
          result += DATA.price[index] * DATA[key] / 100
      }  
  } else {
      if  (key === 'desktopTemplates') {
          result += DATA.price[index] * DATA.desktopTemplates[index] / 100
      }
   /* After this else the website stops functioning normally */
   else {
          result += DATA[key][index];
      }
  } 
})

result += DATA.price[index];

totalPriceSum.textContent = result;
}


 function handlerCallBackForm(event){
 const target = event.target;

  if ( target.classList.contains('want-faster') ) {
  target.checked ? showElem(fastRange) : hideElem(fastRange);
 }

 if (target.classList.contains('calc-handler')) {
  priceCalculation(target);
  }
 }

startButton.addEventListener( 'click', function() {
showElem(mainForm);
hideElem(firstScreen);
} );

endButton.addEventListener('click', function() {

for ( const elem of formCalculate.elements) {
   if(elem.tagName === 'FIELDSET'){
       hideElem(elem);
   }
 }

 showElem(total);

});

formCalculate.addEventListener('change', handlerCallBackForm);

提示:很高兴您提到了行号,但是如果您能在看到错误的行旁边添加注释,这将有助于我们更好地了解错误。您好,我在代码上方进行了注释,然后错误开始。您可以在每个循环的选项下面看到它。