0
I have an Array that has the following items:
[[362, SCAB171570FEC]]
To display this I use the following expression:
return $data.listaItensPedido.value;
But I need for example to access only the 362, tried that expression:
return $data.listaItensPedido.value[0];
And so I was not returned anything. It is possible to access each item of this array?
The code is incomplete. what happens until you arrive at
$data.listaItensPedido.value?– BrTkCa
Forehead
return $data.listaItensPedido.value[0][0];. If you don’t give what appears inconsole.log(typeof $data.listaItensPedido.value);?– Sergio
@Sergio
return $data.listaItensPedido.value[0][0];did not return me anything, I tried to putreturn (typeof $data.listaItensPedido.value);and you were shown this:string– R.Santos
In this case this value is a string, you have to convert from JSON in string to object format. Test:
return JSON.parse($data.listaItensPedido.value)[0][0];– Sergio
@Sergio put this on and I was not shown anything
– R.Santos
:/ What gives
console.log(typeof $data.listaItensPedido.value, $data.listaItensPedido.value);?– Sergio
@Sergio put this
return (typeof $data.listaItensPedido.value, $data.listaItensPedido.value);and returned this to me:[[362, SCAB171570FEC]]– R.Santos
Let’s go continue this discussion in chat.
– R.Santos
@Sergio
console.log(typeof $data.listaItensPedido.value, $data.listaItensPedido.value);showed me this on the console$data.listaItensPedido is undefined– R.Santos
@Lucascosta as well as "what happens"?
– R.Santos
The complete chunk of the code, the form that this variable is populated @R.Santos
– BrTkCa