class Kid { // Constructor for initializing // Kid properties constructor(name, gender, age) { this.name = name; this.gender = gender; this.age = age; } // Define instance methods haveBirthday( ) { this.age++; } toString( ) { return `${this.name};${this.gender};${this.age}`; } } // Test Kid class by creating a Kid object. k = new Kid("Alice", "F", 11); document.writeln(`${k.name} ${k.gender} ${k.age}<br>`); document.writeln(`${k.toString( )} ${k}<br>`; k.haveBirthday( ); document.writeln(k.age);
class Clock { constructor(hr, min, sec) { this.hr = hr; this.min = min; this.sec = sec; } tick( ) { this.sec++; if(this.sec == 60) { this.sec = 0; this.min++; } if(this.min == 60) { this.min = 0; this.hr++; } if(this.hr == 24) { this.hr = 0; } } toString( ) { var h = this.hr.toString( ).padStart(2, "0"); var m = this.min.toString( ).padStart(2, "0"); var s = this.sec.toString( ).padStart(2, "0"); return `${h}:${m}:${s}`; } } c = new Clock(20, 44, 9); document.writeln(c); for(let i = 1; i <= 20000; i++) { c.tick( ); } document.writeln(c);
var lottoObject = new Lotto(30, 5); lottoObject.selectBalls( ); document.writeln(lottoObject + "<br>"); for(let i = 1; i <= 5; i++) { document.writeln(lottoObject.getBall(i)); }
<input> <button> <textarea> <select> <option> <output>HTML Tags Listed Alphabetically (W3Schools)
id class hidden style disabled dragableHTML Global Attributes (W3Schools)
<input> type (button checkbox radio hidden number password color date email file image month range reset search submit tel text time url week) value (text) checked (checkbox) max (number) maxlength (number) minlength (number) multiple (text) pattern (text) placeholder (text) readonly (text) size (number) step (number) <button> <textarea> cols rows readonly maxlength placeholder wrap <select> multiple size <option> value selectedTag Attibutes Listed Alphabetically (W3Schools)
blur change click dblclick focus keydown keypress keyup load mousedown mouseenter mouseleave mousemove mouseup resize scroll select wheel
HTML Events (W3Schools)