Avatar of nikdonovanau
nikdonovanau asked on

Javascript IF ELSE ARRAY

Basically i have a script the creates the following 2 arrays. Both have bloque_id dynamically assigned. EG Bloque1 and Bloque2
for arguments sake the first array below has a bloque_id of Bloque1

window[bloque_id] = new Array();
window[bloque_id][1] = "bannanas";
window[bloque_id][2] = "oranges";

the second array below has a bloque_id of Bloque2
window[bloque_id] = new Array();
window[bloque_id][1] = "bannanas2";
window[bloque_id][2] = "oranges2";

First question is how do i make these arrays global and access them.
Second question how would i do check on their values ?  remembering that i want to access them in a different function globally if that makes sense
say also that the name of one of the arrays is stored in bloque_name as a value

if (window[bloque_name][1] == some value )
{
alert('match found');
}
JavaScript

Avatar of undefined
Last Comment
nikdonovanau

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jose_Jayan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Zvonko

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
nikdonovanau

Thanks guys for that. A+
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck