title: Knockout: Determining which items in an array have been selected
body: <p>Or - Determining whether or not a given item has been selected.  </p>
  
  <p>I have an array of objects that can be "checked" - <strong>if an item's checkbox is checked, some conditional attributes should be activated for the parent element (the color should change)</strong>.  I have the conditional stuff and the checkboxes working, I just can't figure out how to efficiently monitor whether or not each item is currently selected.  </p>
  
  <p>My current implementation iterates over the "selectedItems" array to determine if it contains the target element, for each element.  I feel like this is the worst possible way to accomplish this: </p>
  
  <pre><code>var folderViewModel = function (data) {
      var self = this;
      self.isSelected = ko.computed(function () {
                  var i = publishedSelectedFolders().length;
                  debugger;
                  while (i--) {
                      if (publishedSelectedFolders[i] === self.folderId()) {
                          alert("true");
                          return true;
                      }
                  }
                  return false;
              }, self);
               .....
  </code></pre>
  
  <p>Any tips would be wonderful.  Here's my fiddle (simplified as much as possible): </p>
  
  <p><a href="http://jsfiddle.net/mWXTs/3/" rel="nofollow">http://jsfiddle.net/mWXTs/3/</a></p>