How javascript return each value in the array

if(wqe !== null){
    if(wqe.length > 1){
      for(var i=0;i < wqe.length; iPP){
        console.log(wqe[i])
        return wqe[i]
      }
     
    }
    return wqe
  }

A code as above,

I judge that if the length of an array is greater than one, I run for to grab each value

If

is less than one, that is, if there is only one, the direct threshold value

now there is a problem

if its length is greater than one, suppose it is ["aaa","bbb","nnn"]

my return wqe [I] will only send out the first value in the array, that is, aaa

After

, bbb and nnn will not be passed. I want it to send every value in the same array in order

.

if it comes out in sequence, I want it to send aaa first, then bbb, then nnn, instead of aaa,nnn,nnn all at once.

probably means to call many times, and each time it returns a different meaning

. < hr >

the main reason is that I want to pick up the incoming value in html and display the data through the passed value

It looks something like this on

html. {{test [returnName ()] [0]}}

will capture the data in a certain array according to the value passed

it should be like this when returned

{{ test["aaa"][0] }}
{{ test["bbb"][0] }}
{{ test["ccc"][0] }}

instead of

{{ test["aaa,bbb,ccc"][0] }}

how to change this?

Jul.12,2022

what does it mean in order? isn't it still the wqe array?

-Update
according to the meaning of the subject, this should satisfy you


:

var wqe = ["aaa","bbb","ccc"];

var returnName = ((arr)=>{
  let i=0;
  return () => arr[iPP]
})(wqe);

console.log(returnName()); //aaa
console.log(returnName()); //bbb
console.log(returnName()); //ccc
Menu