Skip to content

Instantly share code, notes, and snippets.

@tak1827
Created December 9, 2018 05:00
Show Gist options
  • Select an option

  • Save tak1827/a9ee11f41ce79f70ad1e7cdd7dd4b656 to your computer and use it in GitHub Desktop.

Select an option

Save tak1827/a9ee11f41ce79f70ad1e7cdd7dd4b656 to your computer and use it in GitHub Desktop.

Revisions

  1. tak1827 created this gist Dec 9, 2018.
    47 changes: 47 additions & 0 deletions sbi-cording-test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@

    /***********
    Discription
    *************/
    // Name: Takayuki Tamura

    /***********
    Text field
    *************/
    function test1(ary) {

    let target;
    for (let i = 0; i < ary.length - 3; i+=3) {
    if(ary[i] !== ary[i+2]) {
    target = i;
    break;
    }
    }

    return typeof target !== 'undefined'
    ? ary[target]
    : ary[ary.length-1];
    }

    function test2(ary) {

    let swp = new Array(ary.length);

    for(let i = 0; i < ary.length; i+=4) {

    if (typeof ary[i+2] !== 'undefined') {
    swp[i] = ary[i+2];
    swp[i+2] = ary[i];
    } else if (typeof ary[i] !== 'undefined') {
    swp[i] = ary[i];
    }

    if (typeof ary[i+3] !== 'undefined') {
    swp[i+1] = ary[i+3];
    swp[i+3] = ary[i+1];
    } else if (typeof ary[i+1] !== 'undefined') {
    swp[i+1] = ary[i+1];
    }
    }

    return swp;
    }