Best way to simplify this code, more efficient

Posted by Derek on Stack Overflow See other posts from Stack Overflow or by Derek
Published on 2010-05-26T00:29:15Z Indexed on 2010/05/26 0:41 UTC
Read the original article Hit count: 274

My question is, is there a way to make this code more efficient or write it in a simple way? javascript by the way.

switch (tempvar1) {
  case 1:
    currentSlide = 'slide1';
    showaslide('ppslide1');
    break;
  case 2:
    currentSlide = 'slide2';
    showaslide('ppslide2');
    break;
  case 3:
    currentSlide = 'slide3';
    showaslide('ppslide3');
    break;
  case 4:
    currentSlide = 'slide4';
    showaslide('ppslide4');
    break;
  case 5:
    currentSlide = 'slide5';
    showaslide('ppslide5');
    break;
  case 6:
    currentSlide = 'slide6';
    showaslide('ppslide6');
    break;
  // 20 total cases
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about efficiency