From fec52d66a0cca53d1290e633151806aaaffb2e7f Mon Sep 17 00:00:00 2001 From: Mika Dumont Date: Mon, 11 Dec 2017 15:13:15 -0800 Subject: [PATCH 1/2] js basics almost done --- basics.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/basics.js b/basics.js index 94aaf06..efbd6ea 100644 --- a/basics.js +++ b/basics.js @@ -1,10 +1,13 @@ /* Create a `myName` variable and assign it a String value */ - +var myName = 'Mika'; /* 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: 27, +}; /* Create a variable called `canDrive`, * if it should be true if your person object is at least 16 years old */ @@ -13,7 +16,10 @@ * it should take a 1 parameter, `name` * and it should print "Hello, my name is {name}" */ - +function greet(name) { + return `Hello, my name is ${name}.` +} +console.log(greet()); /* Create an array called `dataTypes` with atleast 1 of every data type; * (there are 6 different data types); */ @@ -22,3 +28,9 @@ * 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('bark!'); + } +}; \ No newline at end of file From 20fa62ba3b2fea173535847cfe23255d56023f0c Mon Sep 17 00:00:00 2001 From: Mika Dumont Date: Mon, 11 Dec 2017 16:37:38 -0800 Subject: [PATCH 2/2] Finished Basics Challenge --- basics.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/basics.js b/basics.js index efbd6ea..85fbfcb 100644 --- a/basics.js +++ b/basics.js @@ -11,19 +11,22 @@ var person = { /* Create a variable called `canDrive`, * if it should be true if your person object is at least 16 years old */ - +var canDrive = null +if (person.age >= 16) { + canDrive = 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) { - return `Hello, my name is ${name}.` + console.log("Hello, my name is " + name); } -console.log(greet()); +greet('Mika'); /* Create an array called `dataTypes` with atleast 1 of every data type; * (there are 6 different data types); */ - +var dataTypes = [false, 'orange', 0, null, {}, undefined] /* 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'