From a4d45afcf8fec9e6b88a282a72cee1b1be8075e3 Mon Sep 17 00:00:00 2001 From: Bryce Date: Mon, 2 May 2016 00:04:20 -1000 Subject: [PATCH 1/3] Added everything. --- basics.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/basics.js b/basics.js index 94aaf06..9da7deb 100644 --- a/basics.js +++ b/basics.js @@ -1,24 +1,37 @@ /* Create a `myName` variable and assign it a String value */ - +var myName = 'Bryce'; /* 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: myName, + age: 30 +}; /* Create a variable called `canDrive`, * if it should be true if your person object is at least 16 years old */ +var canDrive = person.age >= 16 ? true : false; /* Create a function called `greet`, * it should take a 1 parameter, `name` * and it should print "Hello, my name is {name}" */ - +function greet(name) { + console.log('Hello, my name is ' + name ); +} +greet(person.name); /* Create an array called `dataTypes` with atleast 1 of every data type; * (there are 6 different data types); */ - +var dataTypes = ['string', 3, true, [12], 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', + bark: function () { + console.log("Wan wan b/c I'm Japanese, yo!"); + } +}; From e35fc8b55073d7ad9b9bf654d02862c983fc6564 Mon Sep 17 00:00:00 2001 From: Bryce Date: Mon, 2 May 2016 09:03:40 -1000 Subject: [PATCH 2/3] Added property to person to store the 'canDrive' variable. Added function 'driveAge' to log a statement based on 'canDrive'. Added parameter to 'bark function'. Added multiple 'console.log' to test. --- basics.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/basics.js b/basics.js index 9da7deb..5f5b1d4 100644 --- a/basics.js +++ b/basics.js @@ -8,11 +8,13 @@ var person = { name: myName, age: 30 }; +console.log(person); /* Create a variable called `canDrive`, * if it should be true if your person object is at least 16 years old */ var canDrive = person.age >= 16 ? true : false; - +person.drive = canDrive; +console.log(person); /* Create a function called `greet`, * it should take a 1 parameter, `name` * and it should print "Hello, my name is {name}" @@ -20,18 +22,29 @@ var canDrive = person.age >= 16 ? true : false; function greet(name) { console.log('Hello, my name is ' + name ); } + +function driveAge() { + if (person.drive === true) { + console.log('I can also drive a car!'); + } else { + console.log('I am too young to drive.'); + } +} greet(person.name); +driveAge(); /* Create an array called `dataTypes` with atleast 1 of every data type; * (there are 6 different data types); */ var dataTypes = ['string', 3, true, [12], undefined, null]; +console.log(dataTypes); /* 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', - bark: function () { - console.log("Wan wan b/c I'm Japanese, yo!"); + bark: function (barkSound) { + console.log(barkSound); } }; +dog.bark('wan wan'); \ No newline at end of file From f81197eee1feaa5da5350517acef65a1020f5237 Mon Sep 17 00:00:00 2001 From: Bryce Date: Wed, 4 May 2016 15:55:33 -1000 Subject: [PATCH 3/3] Removed ternary operator for var 'canDrive.' --- basics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basics.js b/basics.js index 5f5b1d4..fa14b8e 100644 --- a/basics.js +++ b/basics.js @@ -12,7 +12,7 @@ console.log(person); /* Create a variable called `canDrive`, * if it should be true if your person object is at least 16 years old */ -var canDrive = person.age >= 16 ? true : false; +var canDrive = person.age >= 16; person.drive = canDrive; console.log(person); /* Create a function called `greet`,