How can I minimize the code lines using (for each)










-3














swiper one



var swiperCurrent;

var swiper = new Swiper('.swiper-container-1',
init: false,
pagination: '.swiper-pagination-1',
nextButton: '.swiper-button-next-1',
prevButton: '.swiper-button-prev-1',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent2(idx)
$('._ooredoo_banner_content_1> div').hide(0);
$('._ooredoo_banner_content_1> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;

);

swiper.init();


swiper two



var swiperCurrent2;

var swiper = new Swiper('.swiper-container-2,
init: false,
pagination: '.swiper-pagination-2',
nextButton: '.swiper-button-next-2',
prevButton: '.swiper-button-prev-2',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent2(idx)
$('._ooredoo_banner_content_2> div').hide(0);
$('._ooredoo_banner_content_2> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent2(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent2 !== el.activeIndex)
showSliderContent2(el.activeIndex);
swiperCurrent2 = el.activeIndex;

);

swiper.init();


swiper three



var swiperCurrent3;

var swiper = new Swiper('.swiper-container-3’,
init: false,
pagination: '.swiper-pagination-3',
nextButton: '.swiper-button-next-3',
prevButton: '.swiper-button-prev-3',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent3(idx)
$('._ooredoo_banner_content_3> div').hide(0);
$('._ooredoo_banner_content_3> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent3(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent3 !== el.activeIndex)
showSliderContent3(el.activeIndex);
swiperCurrent3 = el.activeIndex;

);

swiper.init();









share|improve this question



















  • 1




    what is your question exactly?
    – jtate
    Nov 12 '18 at 20:11










  • It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
    – lemieuxster
    Nov 12 '18 at 20:43















-3














swiper one



var swiperCurrent;

var swiper = new Swiper('.swiper-container-1',
init: false,
pagination: '.swiper-pagination-1',
nextButton: '.swiper-button-next-1',
prevButton: '.swiper-button-prev-1',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent2(idx)
$('._ooredoo_banner_content_1> div').hide(0);
$('._ooredoo_banner_content_1> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;

);

swiper.init();


swiper two



var swiperCurrent2;

var swiper = new Swiper('.swiper-container-2,
init: false,
pagination: '.swiper-pagination-2',
nextButton: '.swiper-button-next-2',
prevButton: '.swiper-button-prev-2',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent2(idx)
$('._ooredoo_banner_content_2> div').hide(0);
$('._ooredoo_banner_content_2> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent2(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent2 !== el.activeIndex)
showSliderContent2(el.activeIndex);
swiperCurrent2 = el.activeIndex;

);

swiper.init();


swiper three



var swiperCurrent3;

var swiper = new Swiper('.swiper-container-3’,
init: false,
pagination: '.swiper-pagination-3',
nextButton: '.swiper-button-next-3',
prevButton: '.swiper-button-prev-3',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent3(idx)
$('._ooredoo_banner_content_3> div').hide(0);
$('._ooredoo_banner_content_3> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent3(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent3 !== el.activeIndex)
showSliderContent3(el.activeIndex);
swiperCurrent3 = el.activeIndex;

);

swiper.init();









share|improve this question



















  • 1




    what is your question exactly?
    – jtate
    Nov 12 '18 at 20:11










  • It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
    – lemieuxster
    Nov 12 '18 at 20:43













-3












-3








-3







swiper one



var swiperCurrent;

var swiper = new Swiper('.swiper-container-1',
init: false,
pagination: '.swiper-pagination-1',
nextButton: '.swiper-button-next-1',
prevButton: '.swiper-button-prev-1',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent2(idx)
$('._ooredoo_banner_content_1> div').hide(0);
$('._ooredoo_banner_content_1> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;

);

swiper.init();


swiper two



var swiperCurrent2;

var swiper = new Swiper('.swiper-container-2,
init: false,
pagination: '.swiper-pagination-2',
nextButton: '.swiper-button-next-2',
prevButton: '.swiper-button-prev-2',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent2(idx)
$('._ooredoo_banner_content_2> div').hide(0);
$('._ooredoo_banner_content_2> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent2(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent2 !== el.activeIndex)
showSliderContent2(el.activeIndex);
swiperCurrent2 = el.activeIndex;

);

swiper.init();


swiper three



var swiperCurrent3;

var swiper = new Swiper('.swiper-container-3’,
init: false,
pagination: '.swiper-pagination-3',
nextButton: '.swiper-button-next-3',
prevButton: '.swiper-button-prev-3',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent3(idx)
$('._ooredoo_banner_content_3> div').hide(0);
$('._ooredoo_banner_content_3> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent3(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent3 !== el.activeIndex)
showSliderContent3(el.activeIndex);
swiperCurrent3 = el.activeIndex;

);

swiper.init();









share|improve this question















swiper one



var swiperCurrent;

var swiper = new Swiper('.swiper-container-1',
init: false,
pagination: '.swiper-pagination-1',
nextButton: '.swiper-button-next-1',
prevButton: '.swiper-button-prev-1',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent2(idx)
$('._ooredoo_banner_content_1> div').hide(0);
$('._ooredoo_banner_content_1> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;

);

swiper.init();


swiper two



var swiperCurrent2;

var swiper = new Swiper('.swiper-container-2,
init: false,
pagination: '.swiper-pagination-2',
nextButton: '.swiper-button-next-2',
prevButton: '.swiper-button-prev-2',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent2(idx)
$('._ooredoo_banner_content_2> div').hide(0);
$('._ooredoo_banner_content_2> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent2(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent2 !== el.activeIndex)
showSliderContent2(el.activeIndex);
swiperCurrent2 = el.activeIndex;

);

swiper.init();


swiper three



var swiperCurrent3;

var swiper = new Swiper('.swiper-container-3’,
init: false,
pagination: '.swiper-pagination-3',
nextButton: '.swiper-button-next-3',
prevButton: '.swiper-button-prev-3',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent3(idx)
$('._ooredoo_banner_content_3> div').hide(0);
$('._ooredoo_banner_content_3> div:eq('+ idx +')').fadeIn(200)


swiper.on('init', function (el)
showSliderContent3(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent3 !== el.activeIndex)
showSliderContent3(el.activeIndex);
swiperCurrent3 = el.activeIndex;

);

swiper.init();






javascript jquery foreach swiper






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 20:32









Scott Sauyet

19.7k22653




19.7k22653










asked Nov 12 '18 at 20:07









user3083972

1




1







  • 1




    what is your question exactly?
    – jtate
    Nov 12 '18 at 20:11










  • It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
    – lemieuxster
    Nov 12 '18 at 20:43












  • 1




    what is your question exactly?
    – jtate
    Nov 12 '18 at 20:11










  • It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
    – lemieuxster
    Nov 12 '18 at 20:43







1




1




what is your question exactly?
– jtate
Nov 12 '18 at 20:11




what is your question exactly?
– jtate
Nov 12 '18 at 20:11












It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
– lemieuxster
Nov 12 '18 at 20:43




It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
– lemieuxster
Nov 12 '18 at 20:43












1 Answer
1






active

oldest

votes


















0














Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map that function over the 1, 2, and 3 partial ids. This means we no longer need the 2 and 3 suffixes on some of the variables; they are only available inside the closures generated by the callback to map.



There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id to distinguish it, great. If not, you might need one ore more additional variables, and the map statement will have to get a little more complex.



const makeSwiper = (id) => 
var swiperCurrent;

var swiper = new Swiper('.swiper-container-2',
init: false,
pagination: `.swiper-pagination-$id`,
nextButton: `.swiper-button-next-$id`,
prevButton: `.swiper-button-prev-$id`,
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10

,
runCallbacksOnInit:true
);

function showSliderContent(idx)
$(`._ooredoo_banner_content_$id> div`).hide(0);
$(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)


swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);

swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;

);

return swiper


const swipers = [1, 2, 3].map(makeSwiper)





share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269351%2fhow-can-i-minimize-the-code-lines-using-for-each%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map that function over the 1, 2, and 3 partial ids. This means we no longer need the 2 and 3 suffixes on some of the variables; they are only available inside the closures generated by the callback to map.



    There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id to distinguish it, great. If not, you might need one ore more additional variables, and the map statement will have to get a little more complex.



    const makeSwiper = (id) => 
    var swiperCurrent;

    var swiper = new Swiper('.swiper-container-2',
    init: false,
    pagination: `.swiper-pagination-$id`,
    nextButton: `.swiper-button-next-$id`,
    prevButton: `.swiper-button-prev-$id`,
    slidesPerView: 3,
    centeredSlides: true,
    paginationClickable: true,
    initialSlide: 2,
    spaceBetween: 22,
    breakpoints:
    992:
    slidesPerView: 1,
    spaceBetween: 10

    ,
    runCallbacksOnInit:true
    );

    function showSliderContent(idx)
    $(`._ooredoo_banner_content_$id> div`).hide(0);
    $(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)


    swiper.on('init', function (el)
    showSliderContent(el.activeIndex);
    );

    swiper.on('transitionEnd', function (el)
    if(swiperCurrent !== el.activeIndex)
    showSliderContent(el.activeIndex);
    swiperCurrent = el.activeIndex;

    );

    return swiper


    const swipers = [1, 2, 3].map(makeSwiper)





    share|improve this answer

























      0














      Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map that function over the 1, 2, and 3 partial ids. This means we no longer need the 2 and 3 suffixes on some of the variables; they are only available inside the closures generated by the callback to map.



      There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id to distinguish it, great. If not, you might need one ore more additional variables, and the map statement will have to get a little more complex.



      const makeSwiper = (id) => 
      var swiperCurrent;

      var swiper = new Swiper('.swiper-container-2',
      init: false,
      pagination: `.swiper-pagination-$id`,
      nextButton: `.swiper-button-next-$id`,
      prevButton: `.swiper-button-prev-$id`,
      slidesPerView: 3,
      centeredSlides: true,
      paginationClickable: true,
      initialSlide: 2,
      spaceBetween: 22,
      breakpoints:
      992:
      slidesPerView: 1,
      spaceBetween: 10

      ,
      runCallbacksOnInit:true
      );

      function showSliderContent(idx)
      $(`._ooredoo_banner_content_$id> div`).hide(0);
      $(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)


      swiper.on('init', function (el)
      showSliderContent(el.activeIndex);
      );

      swiper.on('transitionEnd', function (el)
      if(swiperCurrent !== el.activeIndex)
      showSliderContent(el.activeIndex);
      swiperCurrent = el.activeIndex;

      );

      return swiper


      const swipers = [1, 2, 3].map(makeSwiper)





      share|improve this answer























        0












        0








        0






        Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map that function over the 1, 2, and 3 partial ids. This means we no longer need the 2 and 3 suffixes on some of the variables; they are only available inside the closures generated by the callback to map.



        There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id to distinguish it, great. If not, you might need one ore more additional variables, and the map statement will have to get a little more complex.



        const makeSwiper = (id) => 
        var swiperCurrent;

        var swiper = new Swiper('.swiper-container-2',
        init: false,
        pagination: `.swiper-pagination-$id`,
        nextButton: `.swiper-button-next-$id`,
        prevButton: `.swiper-button-prev-$id`,
        slidesPerView: 3,
        centeredSlides: true,
        paginationClickable: true,
        initialSlide: 2,
        spaceBetween: 22,
        breakpoints:
        992:
        slidesPerView: 1,
        spaceBetween: 10

        ,
        runCallbacksOnInit:true
        );

        function showSliderContent(idx)
        $(`._ooredoo_banner_content_$id> div`).hide(0);
        $(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)


        swiper.on('init', function (el)
        showSliderContent(el.activeIndex);
        );

        swiper.on('transitionEnd', function (el)
        if(swiperCurrent !== el.activeIndex)
        showSliderContent(el.activeIndex);
        swiperCurrent = el.activeIndex;

        );

        return swiper


        const swipers = [1, 2, 3].map(makeSwiper)





        share|improve this answer












        Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map that function over the 1, 2, and 3 partial ids. This means we no longer need the 2 and 3 suffixes on some of the variables; they are only available inside the closures generated by the callback to map.



        There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id to distinguish it, great. If not, you might need one ore more additional variables, and the map statement will have to get a little more complex.



        const makeSwiper = (id) => 
        var swiperCurrent;

        var swiper = new Swiper('.swiper-container-2',
        init: false,
        pagination: `.swiper-pagination-$id`,
        nextButton: `.swiper-button-next-$id`,
        prevButton: `.swiper-button-prev-$id`,
        slidesPerView: 3,
        centeredSlides: true,
        paginationClickable: true,
        initialSlide: 2,
        spaceBetween: 22,
        breakpoints:
        992:
        slidesPerView: 1,
        spaceBetween: 10

        ,
        runCallbacksOnInit:true
        );

        function showSliderContent(idx)
        $(`._ooredoo_banner_content_$id> div`).hide(0);
        $(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)


        swiper.on('init', function (el)
        showSliderContent(el.activeIndex);
        );

        swiper.on('transitionEnd', function (el)
        if(swiperCurrent !== el.activeIndex)
        showSliderContent(el.activeIndex);
        swiperCurrent = el.activeIndex;

        );

        return swiper


        const swipers = [1, 2, 3].map(makeSwiper)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 '18 at 20:44









        Scott Sauyet

        19.7k22653




        19.7k22653



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269351%2fhow-can-i-minimize-the-code-lines-using-for-each%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto