Note that there are some explanatory texts on larger screens.

plurals
  1. POGet previous object id which isn't disabled
    primarykey
    data
    text
    <p>Dear Stackoverflowers,</p> <p>I got the following object and function, but if i give 0 as parameters it bugs! Please help me out since i have only 1,5 hour left to deliver this.</p> <pre><code>var album = [ { url: 'images/0006787.jpg', landscape: true, description: 'Shadows to the sea...', photographer: 'Sander', date: '12-8-1999' }, { url: 'images/0004713.jpg', description: 'Amsterdam? Utrecht? Die fiets ben je kwijt!', landscape: false }, { url: 'images/0004720.jpg', landscape: false }, { url: 'images/0004731.jpg', landscape: true }, { url: 'images/0004750.jpg', landscape: true }, { url: 'images/0004755.jpg', landscape: true }, { url: 'images/0004801.jpg', landscape: true }, { url: 'images/0004802.jpg', landscape: false }, { url: 'images/0004827.jpg', landscape: false }, { url: 'images/0004853.jpg', landscape: false }, { url: 'images/0004858.jpg', landscape: true }, { url: 'images/0004860.jpg', landscape: true }, { url: 'images/0004870.jpg', landscape: true }, { url: 'images/0004874.jpg', landscape: false }, { url: 'images/0004888.jpg', landscape: true }, { url: 'images/0004902.jpg', landscape: true }, { url: 'images/0004931.jpg', landscape: true }, { url: 'images/0004969.jpg', landscape: true }, { url: 'images/0004971.jpg', landscape: true }, { url: 'images/0006598.jpg', landscape: true }, { url: 'images/0006630.jpg', landscape: true }, { url: 'images/0006638.jpg', landscape: true }, { url: 'images/0006680.jpg', landscape: true }, { url: 'images/0006743.jpg', landscape: true }, { url: 'images/0004681.jpg', landscape: false } ]; </code></pre> <p>The function:</p> <pre><code>function getPrev(currPhotoId) { var i = currPhotoId - 1; i %= album.length; while ( album[i].disabled ) { i--; i %= album.length; } return i; } </code></pre> <p>Now the purpose of this function is that it checks if the previous row has the property disabled, if it does it scans until it finds one without the disabled property.</p> <p>For example getPrev(0) should return last in object in this case. But, if i the last in object to disabled = true, it should scan backwards untill it reaches one without the disabled property</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload