From cc88dd3e4a33471f890c4162ca54127116d97550 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 9 Dec 2017 17:10:15 -1000 Subject: [PATCH 1/3] Add almost finished but greet function wont take global var --- basics.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/basics.js b/basics.js index 94aaf06..7493901 100644 --- a/basics.js +++ b/basics.js @@ -1,24 +1,50 @@ /* Create a `myName` variable and assign it a String value */ - +var myName= "Nick"; /* Create a `person` variable and give it 2 properties, * `name`, assign it the same name as before, * as well as an `age` (number); */ - +var person = { + name:"Nick", + age: 26 +}; /* Create a variable called `canDrive`, * if it should be true if your person object is at least 16 years old */ + var canDrive= age; + if( canDrive>=16){ + return true; + } /* Create a function called `greet`, * it should take a 1 parameter, `name` * and it should print "Hello, my name is {name}" */ +function greet(name){ + alert("Hello, my name is " + person.name); + } + + +greet(); /* Create an array called `dataTypes` with atleast 1 of every data type; * (there are 6 different data types); */ + var dataTypes=["str",5,false,["arr"],undefined,null]; + /* Create a `dog` object * it should have a `bark` function that makes your dog bark! * It should also have a name attribute with the value of 'Spot' */ +var dog={ + name:"Spot" +}; + +function speak(){ + var request = prompt("type speak"); + if(request.toLowerCase()==="speak"){ + alert("Arf-Arf!"); + } +}; +speak(); \ No newline at end of file From 0c5431884ee2fe31156fd515c3084ffc92a466fc Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 9 Dec 2017 17:33:29 -1000 Subject: [PATCH 2/3] Add fixed canDrive --- basics.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/basics.js b/basics.js index 7493901..da292b2 100644 --- a/basics.js +++ b/basics.js @@ -11,10 +11,11 @@ var person = { /* Create a variable called `canDrive`, * if it should be true if your person object is at least 16 years old */ - var canDrive= age; - if( canDrive>=16){ - return true; + var canDrive; + if( person.age >= 16){ + canDrive = true; } + console.log(canDrive); /* Create a function called `greet`, * it should take a 1 parameter, `name` From ab9f297d7e5f53d092a34bee2806778769af2ee1 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 9 Dec 2017 17:58:09 -1000 Subject: [PATCH 3/3] Add changed alert to document.write & speak to bark --- basics.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basics.js b/basics.js index da292b2..f1f4c92 100644 --- a/basics.js +++ b/basics.js @@ -23,7 +23,7 @@ var person = { */ function greet(name){ - alert("Hello, my name is " + person.name); + document.write("Hello, my name is " + person.name); } @@ -42,10 +42,10 @@ var dog={ name:"Spot" }; -function speak(){ +function bark(){ var request = prompt("type speak"); if(request.toLowerCase()==="speak"){ alert("Arf-Arf!"); } }; -speak(); \ No newline at end of file +bark(); \ No newline at end of file