Jump to content

JKowalski

Members
  • Content Count

    1
  • Joined

  • Last visited

Everything posted by JKowalski

  1. Hello, to my experience the following does not work (tryit-editor w3School), but it does with a "while" loop instead. Are "for" loops not allowed within classes? <p id="demo">result</p> class Test{ counter(){ var result=0; for(i=0;i<10;i++){ result++; } return result; } counter2(){ var result=0; while(result<10){ result++; } return result; } } var obj=new Test(); document.getElementById("demo").innerHTML=obj.counter(); //document.getElementById("demo").innerHTML=obj.counter2();
×
×
  • Create New...