Parminder
Parminder

Reputation: 191

Search value in associative array javascript

JAVASCRIPT

    var error = new Object ({'1a':'1','1b':'1','2a':'1'}); // like this I have defined around 200 values
    if (some condition is true)
          error[id] = 0;  // id is selected dynamically ( '1a' or '1b' or what ever)

when all this is done I want to check if any one in Object error still have value '1' or not. I have used the following but it does not seem to work..

    for ( i in error)
          if(error[i].value == '1')   -some code-  // this line gives error, not able to read value

what should be the correct method...??

Upvotes: 0

Views: 635

Answers (1)

nicael
nicael

Reputation: 18995

Simply remove .value:

if(error[i] == '1'){...}

Upvotes: 1

Related Questions