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


Groups > comp.lang.javascript > #36090

Re: Cant pop and slice first second element

Newsgroups comp.lang.javascript
Date 2019-03-06 07:42 -0800
References <ebc71280-6e53-4a6a-b11b-3e00a67031d3@googlegroups.com> <XnsAA0A7B698473Aeejj99@194.109.6.166>
Message-ID <d9c040cd-78af-4d59-898f-ae98fc87ff53@googlegroups.com> (permalink)
Subject Re: Cant pop and slice first second element
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
> Mar 2019 in comp.lang.javascript: 
> 
> > I have an trackarray where i want to be able remove all but first
> > element. 
> > 
> > If i stand on last element i pop it otherwise i slice it. But if i pop
> > all tracks, i never able to pop track 2. Similar when splice invoked it
> > will not splice when standing on track one, and stop remove tracks when
> > it removed all beyond track 2. "Because then pop is invoked", i probably
> > should used length instead of maxtrack. 
> > 
> > function removeTrack(tracknr){
> > console.log(maxtrack+" AND "+tracknr);
> > if (maxtrack>1){ 
> 
> Wrong counting and thinking, try:
> 
> if (maxtrack>0){
> 
> 
> > if (maxtrack==tracknr){ track.pop(); tracknr--;
> > maxtrack--;document.getElementById("track").value--;} else
> > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
> >}
> 
> 
> 
> 
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Thank's Evertjan, unfortunately it is not it. I suspect something goes wrong out side function, i really do not get it because after i set to zero. I still can't remove the two last tracks but they are visually written out, but they can't be there because tracknr = maxtrack is down at zero. I will have to check what is going on elsewhere, because the maxtrack and tracknr goes down to zero but the two tracks still written out. I have to check track.length with console.log.

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


Thread

Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 01:41 -0800
  Re: Cant pop and slice first second element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-03-06 12:07 +0100
    Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 07:42 -0800
      Re: Cant pop and slice first second element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-03-06 18:46 +0100
        Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 10:05 -0800
          Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 10:13 -0800
          Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 10:17 -0800
          Re: Cant pop and slice first second element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-03-06 23:52 +0100
    Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 08:45 -0800
      Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 09:19 -0800
        Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 09:42 -0800

csiph-web