javascript代码出错了

javascript代码出错了

本文介绍了javascript代码出错了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该能够从以下数据集中获取用户给出的剧集和季节的信息





https: //s3-ap-southeast-1.amazonaws.com/edwisor-india-bucket/assignments/we

b03 / JSS1l2 / bigbangtheory.json



我尝试过的事情:



i was supposed to be able to get the info of episode and season given by the user from following dataset


https://s3-ap-southeast-1.amazonaws.com/edwisor-india-bucket/assignments/we
b03/JSS1l2/bigbangtheory.json

What I have tried:

let obtain=(season,episode)=>

{
  var seasonfound=false
  var episodefound=false
  for (var i of information.embedded.episode)
  {
    if(information.embedded.episode[i].season==season)
    {
      if(information.embedded.episode[i].number==episode)
      {
        seasonfound=true
        episodefound=true
         break
      }
      else{
        seasonfound=true
        episodefound=false
        break
      }
    }
    else
    {
      seasonfound=false
    }
  }
  if (seasonfound==true && episodefound==true)
  {

    alert(info[i].id)
  }
  else{
    alert('incorrect')
  }

   

     }

 

let S=window.prompt('enter the seaseon you wish')

let E=window.prompt('enter the episode you wish')

obtain(S,E)

推荐答案

let obtain=(season,episode)=>
{
  var found=false
  for (var i of information.embedded.episode)
  {
    if (  (information.embedded.episode[i].season==season) && (information.embedded.episode[i].number==episode) )
    {
      found=true;
    }
  }
  if (found==true)
  {
    alert(info[i].id)
  }
  else{
    alert('incorrect')
  }

   

     }

 

let S=window.prompt('enter the seaseon you wish')

let E=window.prompt('enter the episode you wish')

obtain(S,E)


这篇关于javascript代码出错了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 09:04