javascript - need help with a condition while looping through an array -


i have array 20 elements, , need few if statements while looping through array , need in creating if statement in sense need able search if string contains text in efficient way won't hang whole app.

var locations = [                    ['maryland', 'usa', 'pentium iv', 120, '1 gb', '15"'],                    ['new york', 'usa', 'pentium iv', 40, '512 mb', '15" , 17"'],               ['frankfurt', 'germany', 'pentium iv', 100, '2 gb', '17"']                 ];  (var = 0; < locations.length; i++) {      var ram = locations[4];      var monitor = locations[5];       // need if statement below      if (ram < '1 gb' || monitor.startswith("15")) {        //      } } 

i using pure javascript, no jquery or other frameworks.

thank in advance help.

how

if (ram.indexof('gb') >= 0) 

this check if word 'gb' contained in string. if is, we're sure it's 1gb, 2gb, etc. if it's not, we're talking in mb, since terabytes of ram not used in machines yet.

offcourse depends on possible choices of ram are. come (finite) list, or can users type them themselves?


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -