Question: I need to debug this function. It is saying CANNTO READ PROPERTIES OF NULL(reading zero) function clicked() {

I need to debug this function. It is saying CANNTO READ PROPERTIES OF NULL(reading zero)

 

 

 

 

 

 

function clicked() {


     
var search = document.getElementById("search");
var results = localStorage.getItem(search);

if(results = null)
 {
  document.getElementById("results").innerHTML = "There are no results for that route name."
 }
 else
 {
 
           var stops = results;
  var output='';

  for(var key in stops[0])
  {
               //5
   var output = output + '' + key + ' : ' + stops[0][key] + '
';
  }
  document.getElementById("result").innerHTML = output;
 }


};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It looks like there are a couple of issues in your code that need to be fixed 1 In the if statement ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!