Javascript 增量然后每隔10次递减

Javascript 增量然后每隔10次递减,javascript,Javascript,我正在为fantasy创建一个草稿应用程序。正因为如此,每10次选秀,球队就会向后选秀。有没有一种简单的方法可以做到这一点,或者我需要写一个长的if/else、switch、extstation 例如: 选秀队 1 - 1 2 - 2 3 - 3 4 -4 5 - 5 7 - 7 8 - 8 9 - 9 10 - 10 11 - 10 12 - 9 等等 创建一个布尔变量来存储递增或递减的天气,然后创建一个字节来存储递增/递减的次数,并创建一

我正在为fantasy创建一个草稿应用程序。正因为如此,每10次选秀,球队就会向后选秀。有没有一种简单的方法可以做到这一点,或者我需要写一个长的if/else、switch、extstation

例如:

选秀队 1 - 1 2 - 2 3 - 3 4 -4 5 - 5 7 - 7 8 - 8 9 - 9 10 - 10 11 - 10 12 - 9 等等
创建一个布尔变量来存储递增或递减的天气,然后创建一个字节来存储递增/递减的次数,并创建一个循环。将if/else与布尔值一起使用。不要忘记每次翻转布尔值。

类似这样的操作应该可以完成任务:


你的代码怎么样?用一个变量来保存一个乘数,可以是+1,也可以是-1。每当拾取是10的倍数时,请切换符号。10-| 10-n |+%20
var total_picks = 100;
var current_pick = 1;
var current_team = 1;
var my_test = true;

for (var i = 0; i < total_picks; i++) {

  // In this "if" statement, the team number will count up from 1 to 10
  if (my_test) {

    // Do whatever you want to with the current pick here
    current_pick++;

    // Do whatever you want to with the current team here
    current_team++;

    if (current_team == 10) {
      my_test = false;
    }
  } else {
    // In this "else" statement, the team number will count down from 10 to 1

    // Do whatever you want to with the current pick here
    current_pick++;

    // Do whatever you want to with the current team here
    current_team--;
    if (current_team == 0) {
      my_test = true;
    }
  }
}