Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19559

Re: About keeping my array 1 based after having sorted it

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: About keeping my array 1 based after having sorted it
Date 2013-05-01 22:12 +0000
Organization A noiseless patient Spider
Message-ID <kls3vj$6b7$4@dont-email.me> (permalink)
References <klrbhd$duk$1@dont-email.me> <guagt.23460$zH4.10295@newsfe13.iad> <XnsA1B3C892E7F06eejj99@194.109.133.133>

Show all headers | View raw


On Wed, 01 May 2013 19:43:01 +0200, Evertjan. wrote:

> Daniel Pitts wrote on 01 mei 2013 in comp.lang.javascript:
> 
>> Alternatively, instead of using 1 base, use 0 base and when you need
>> "every third element", for (var i = 2; i < bookingArray.length; i+=3)
>> 
>> 
> for (var i = 0; i < bookingArray.length/3; i++)
>     x = bookingArray[i * 3 + 1];

I think the last "+ 1" should be +2

0 indexed, the first element he wants (with i = 0) is element [2] (the 
third element)

but x above will be element [1] when i = 0 ( 0 * 3 + 1 )

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

About keeping my array 1 based after having sorted it "Tony" <tony.johansson@inport.com> - 2013-05-01 17:18 +0200
  Re: About keeping my array 1 based after having sorted it Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-01 08:26 -0700
    Re: About keeping my array 1 based after having sorted it "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-01 19:43 +0200
      Re: About keeping my array 1 based after having sorted it Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-01 15:15 -0700
        Re: About keeping my array 1 based after having sorted it "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-02 09:35 +0200
          Re: About keeping my array 1 based after having sorted it Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-02 14:31 +0000
      Re: About keeping my array 1 based after having sorted it Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-01 22:12 +0000
        Re: About keeping my array 1 based after having sorted it "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-02 09:36 +0200
  Re: About keeping my array 1 based after having sorted it Scott Sauyet <scott.sauyet@gmail.com> - 2013-05-02 08:52 -0700
    Re: About keeping my array 1 based after having sorted it Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-03 01:26 +0200
      Re: About keeping my array 1 based after having sorted it Scott Sauyet <scott.sauyet@gmail.com> - 2013-05-03 08:53 -0700
        Re: About keeping my array 1 based after having sorted it Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-03 18:39 +0200
          Re: About keeping my array 1 based after having sorted it Scott Sauyet <scott.sauyet@gmail.com> - 2013-05-03 11:00 -0700
            Sorting arrays of objects (was: About keeping my array 1 based after having sorted it) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-05 01:00 +0200
              Re: Sorting arrays of objects (was: About keeping my array 1 based after having sorted it) Scott Sauyet <scott.sauyet@gmail.com> - 2013-05-05 08:53 -0700
        Re: About keeping my array 1 based after having sorted it Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-05-04 16:14 +0100

csiph-web