0

I have a hashmap (hmA) that I loop through assigning values to the index.

Example:

hmA[0] = 02
hmA[1] = 04
hmA[2] = 02

What I am looking to do is, if the value already exists in the hashmap, place that value in a second hashmap (hmB). The reason I am trying to do this is because I am placing values onto an excel sheet and depending on if the values appear once or twice (like 02 in this case), I place a set of values in specific locations of my excel sheet.

Thanks for the help

scrayon
  • 491
  • 4
  • 14
  • 29
  • 1
    So, `hmA` is an object? Using an array might be more appropriate here. – Felix Kling Nov 18 '13 at 16:30
  • Yes, you can count hmA as an object, I define it as hmA=[] in the beginning – scrayon Nov 18 '13 at 16:32
  • Well, then `hmA` is an array ;) (I know that arrays are objects a well, but arrays provide additional methods which could be helpful in this use case) – Felix Kling Nov 18 '13 at 16:32
  • 1
    looking at the code ... its not a hashmap, its an array. And you are storing numbers in **octal**. But `if (hmA.indexOf(val) !== -1)hmB.push(val)` is probably what you are looking for. – c69 Nov 18 '13 at 16:32
  • possible duplicate of [array.contains(obj) in JavaScript](http://stackoverflow.com/questions/237104/array-containsobj-in-javascript) – Felix Kling Nov 18 '13 at 16:35

0 Answers0