These are chat archives for filearts/plunker

28th
May 2018
welshjs
@welshjs
May 28 2018 11:25

Stupid question

I'm getting a JSLint error warning me not to put functions in a loop

    for (let i = 1; i <= 6; i++) {
      let list0 = function() {
        return "<input type='checkbox' name='check' value='" + myList.indexOf(myList[i]) + "'" + "id='ch" + [i] + "'" + "/><label for='ch" + [i] + "'>" + myList[i] + "<br />";
      };
      $("#legend0").append(list0());
    }

  for (let i = 7; i <= 8; i++) {
    let list1 = function() {
      return "<input type='checkbox' name='check' value='" + myList.indexOf(myList[i]) + "'" + "id='ch" + [i] + "'" + "/><label for='ch" + [i] + "'>" + myList[i] + "<br />";
    };
    $("#legend1").append(list1());
  }

  for (let i = 9; i <= 25; i++) {
    let list2 = function() {
      return "<input type='checkbox' name='check' value='" + myList.indexOf(myList[i]) + "'" + "id='ch" + [i] + "'" + "/><label for='ch" + [i] + "'>" + myList[i] + "<br />";
    };
    $("#legend2").append(list2());
  }

How do I generalize the function so I can re-use it in several loops?

@KennethWeiss yes, you click the gear icon on the right and choose Vim from key binding pulldown.
poloarun
@poloarun
May 28 2018 11:40
Hi
don't have an option to angular2 project
don't have an option to create angular2 project