0

Suppose,

below is my dummy code with my scenario:

Hello.js file:

function hello(data){
   var newlist = []

   if(something == true){
      for(let d in data){
          newlist.push([d[tag]])
          console.log("inside loop",newlist)   //here it is printing the newlist logs as for loop goes on.
      }
     console.log("outside loop",newlist)  //but it is not printing anything here
   }
   console.log(newlist)   //but it is not printing anything here also.
   return newlist         //also not returning the newlist.
}

Here, please help me with the solution for this issue or atleast if you can give any idea what exactly can be the issue.

  • 1
    Your dummy code doesn't do what you think it would, nor it reproduces the issue. `d` in the loop is a string (the name of the property in `data`). Please add your real code and an example of `data` to the post instead of this dummy code. Your issue is most likely solved [in this post](https://stackoverflow.com/q/14220321/1169519). – Teemu Jan 05 '23 at 08:39

0 Answers0