_mercury β 19-03 Jul 23
I have an array of objects like above ... suppose it has many objs
So how to get the object with abbreviation
en-US
? from the array by array accessing ?
labels['en-US
]` seems not to work ..
it should be one line because i use it in EJS view engine16 Replies
Like this?
mmm
Ok thx , i think i should remap the array of objs
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
yes
so how i convert this to an array
to get the label by
locals[abbreviation]
to be easy to access @ScriptyChris
Use
.find()
instead of .filter()
so it will give you first object, which has 'en-US' as abbreviation
and then you can use object.abbreviation
I am thinking of restructure the obove obj
What do you mean?
This does not work
You may understand what i mean from the code
Instead of array of objs
It should be easy to be associative array ? Key : abbreviation, value : label
I don't have idea what are you trying to do π€
What structure do you want to have as an output?
thx for your active help
I did it
if there is a better way , thx to tell
This should work
Very good .. works
Okay
This thread hasnβt had any activity in 12 hours, so itβs now locked.
Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1000478230899327086