File tree Expand file tree Collapse file tree 3 files changed +110
-0
lines changed Expand file tree Collapse file tree 3 files changed +110
-0
lines changed Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < title > Ducks</ title >
5+ < meta charset ="utf-8 ">
6+ < script >
7+ function Duck ( sound ) {
8+ this . sound = sound ;
9+ this . quack = function ( ) {
10+ console . log ( this . sound ) ;
11+ } ;
12+ }
13+ var toy = new Duck ( "quack quack" ) ;
14+ toy . quack ( ) ;
15+ console . log ( typeof toy ) ;
16+ console . log ( toy instanceof Duck ) ;
17+ </ script >
18+ </ head >
19+ < body >
20+ </ body >
21+ </ html >
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < title > Testing typeof</ title >
5+ < meta charset ="utf-8 ">
6+ < script >
7+ var test1 = "abcdef" ;
8+ var test2 = 123 ;
9+ var test3 = true ;
10+ var test4 = { } ;
11+ var test5 = [ ] ;
12+ var test6 ;
13+ var test7 = { "abcdef" : 123 } ;
14+ var test8 = [ "abcdef" , 123 ] ;
15+ function test9 ( ) {
16+ return "abcdef"
17+ } ;
18+ var test10 = null ;
19+ console . log ( typeof test1 ) ;
20+ console . log ( typeof test2 ) ;
21+ console . log ( typeof test3 ) ;
22+ console . log ( typeof test4 ) ;
23+ console . log ( typeof test5 ) ;
24+ console . log ( typeof test6 ) ;
25+ console . log ( typeof test7 ) ;
26+ console . log ( typeof test8 ) ;
27+ console . log ( typeof test9 ) ;
28+ console . log ( typeof test10 ) ;
29+ </ script >
30+ </ head >
31+ < body >
32+ </ body >
33+ </ html >
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < title > Types</ title >
5+ < meta charset ="utf-8 ">
6+ < script >
7+
8+ function lieDetectorTest ( ) {
9+ var lies = 0 ;
10+
11+ var stolenDiamond = { } ;
12+ if ( stolenDiamond ) {
13+ console . log ( "You stole the diamond" ) ;
14+ lies ++ ;
15+ }
16+
17+ var car = {
18+ keysInPocket : null
19+ } ;
20+ if ( car . keysInPocket ) {
21+ console . log ( "Uh oh, guess you stole the car!" ) ;
22+ lies ++ ;
23+ }
24+ if ( car . emptyGasTank ) {
25+ console . log ( "You drove the car after you stole it!" ) ;
26+ lies ++ ;
27+ }
28+
29+ var foundYouAtTheCrimeScene = [ ] ;
30+ if ( foundYouAtTheCrimeScene ) {
31+ console . log ( "A sure sign of guilt" ) ;
32+ lies ++ ;
33+ }
34+ if ( foundYouAtTheCrimeScene [ 0 ] ) {
35+ console . log ( "Caught with a stolen item!" ) ;
36+ lies ++ ;
37+ }
38+
39+ var yourName = " " ;
40+ if ( yourName ) {
41+ console . log ( "Guess you lied about your name" ) ;
42+ lies ++ ;
43+ }
44+ return lies ;
45+ }
46+ var numberOfLies = lieDetectorTest ( ) ;
47+ console . log ( "You told " + numberOfLies + " lies!" ) ;
48+ if ( numberOfLies >= 3 ) {
49+ console . log ( "Guilty as charged" ) ;
50+ }
51+
52+ </ script >
53+ </ head >
54+ < body >
55+ </ body >
56+ </ html >
You can’t perform that action at this time.
0 commit comments