From 71b01752ac01bc8de8f2736c567fef2636543796 Mon Sep 17 00:00:00 2001 From: Martin Raquion Date: Tue, 28 May 2019 16:04:15 +0800 Subject: [PATCH 1/6] modified user.json --- user.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user.json b/user.json index 4ac80a0..02b0215 100644 --- a/user.json +++ b/user.json @@ -1,4 +1,4 @@ { - "name": "", - "email": "" + "name": "Martin Earl Raquion", + "email": "martin.raquion@boom.camp" } From 3a9767b0fb598f161bcadae1d6dc8cb241db3b21 Mon Sep 17 00:00:00 2001 From: Martin Raquion Date: Tue, 28 May 2019 16:08:04 +0800 Subject: [PATCH 2/6] modified test/spec files fo the Jasmine Spec Runner errors --- test/spec/arrayPropertySpec.js | 8 -------- test/spec/quizAppSpec.js | 8 +------- test/spec/sayNameSpec.js | 8 +------- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 6907a75..57b7c39 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,11 +1,3 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); - if (isNode()) { // test if file is running in a node process const fs = require('fs'); diff --git a/test/spec/quizAppSpec.js b/test/spec/quizAppSpec.js index 8e0c63c..c25af04 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,10 +1,4 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); + if (isNode()) { // test if file is running in a node process diff --git a/test/spec/sayNameSpec.js b/test/spec/sayNameSpec.js index 7fbb7bb..d3e211f 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -1,10 +1,4 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); + if (isNode()) { // test if file is running in a node process From 84e50cbba19613243a51c766211f119a840ce1c4 Mon Sep 17 00:00:00 2001 From: Martin Raquion Date: Tue, 28 May 2019 16:30:28 +0800 Subject: [PATCH 3/6] Solved instanceArray.js --- instanceArray.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/instanceArray.js b/instanceArray.js index ab752ac..0029c68 100644 --- a/instanceArray.js +++ b/instanceArray.js @@ -14,28 +14,43 @@ var User = function(name, email, pw){ //Create an Array called 'users' that will store all our instances of User. //code here + var users = []; //Now create and push into your users array 3 separate instances of User using the data from above in that exact order //code here + var aodhanInfo = new User('Aodhan', 'aodhan@boom.camp', 'iLoveJS') + users.push(aodhanInfo); + var gregInfo = new User('Greg', 'greg@boom.camp', 'iLovePython'); + users.push(gregInfo); + var oscarInfo = new User('Oscar', 'oscar@boom.camp', 'iLoveSoccer'); + users.push(oscarInfo); + console.log('Aodhan\'s information is '); //Console.log all of Aodhan information //code here + console.log(aodhanInfo); console.log('Oscar\'s information is '); //Now console.log all of Oscars information //code here + console.log(oscarInfo); //Now create another instance of User using your own information and then add that to your users array. //code here + var martinInfo = new User('Martin', 'martin.raquion@boom.camp', 'iLoveMusic') + users.push(martinInfo); console.log('All my users names are '); //Now loop through your users Array and console.log every users name. //code here + for(let x in users){ + console.log(users[x].name); +} \ No newline at end of file From 05c020e7b9ae900e841ae67de62f25b8a092ab5e Mon Sep 17 00:00:00 2001 From: Martin Raquion Date: Tue, 28 May 2019 16:41:45 +0800 Subject: [PATCH 4/6] Solved sayName.js --- sayName.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sayName.js b/sayName.js index 6e28b51..941655a 100644 --- a/sayName.js +++ b/sayName.js @@ -2,12 +2,22 @@ //code here + var Person = function(name, age){ + this.name = name, + this.age = age + } + //Now create three instances of Person with data you make up //code here - + var martin = new Person('Martin', 21); + var cecille = new Person ('Cecille', 23); + var carl = new Person('Carl', 25); //Now add a sayName method on your Person class that will alert the name of whatever Person instance called it. //code here + Person.prototype.sayName = function(name){ + alert(this.name); + } From df7db760cb111b3e3d43a6bb2fde96ae1e26164f Mon Sep 17 00:00:00 2001 From: Martin Raquion Date: Tue, 28 May 2019 16:54:37 +0800 Subject: [PATCH 5/6] Solved arrayProperty.js --- arrayProperty.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arrayProperty.js b/arrayProperty.js index 2287a36..63ea78f 100644 --- a/arrayProperty.js +++ b/arrayProperty.js @@ -2,4 +2,8 @@ //Add a reverse method to the String 'class' so that every instance of String can call reverse and reverse itself. - //code here \ No newline at end of file + //code here + String.prototype.reverse = function(str){ + let reversed= this.split("").reverse().join(""); + return reversed; + } From 27e94c962eeb964f55b60cac42810c30dfd817ca Mon Sep 17 00:00:00 2001 From: Martin Raquion Date: Tue, 28 May 2019 17:24:00 +0800 Subject: [PATCH 6/6] Solved quizApp.js --- quizApp.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/quizApp.js b/quizApp.js index 083bd6c..a337dbe 100644 --- a/quizApp.js +++ b/quizApp.js @@ -7,26 +7,46 @@ //code here + var QuizUser = function(name, email, password, totalScore){ + this.name = name, + this.email = email, + this.password = password, + this.totalScore = totalScore + } + //Create a Question constructor that accepts title, answersArray, rightAnswer, and difficulty parameters //code here + let Question = function(title, answersArray, rightAnswer, difficulty){ + this.title = title, + this.answersArray = answersArray, + this.rightAnswer = rightAnswer, + this.difficulty = difficulty + } //Create a quizUsers Array which is going to hold all of our users. //code here + let quizUsers = []; //Let's say three people signed up for our service, create 3 instances of User and add each to the users Array //code here + var martin = new QuizUser('Martin', 'martin@boom.camp', 'martinquiz', 95); + var cecille = new QuizUser('Cecille','ceccile@boom.camp','cecillequiz', 96); + var carl = new QuizUser('Carl','carl@boom.camp', 'carlquiz', 97); + quizUsers.push(martin,cecille,carl); + //Create a questions Array which is going to hold all of our questions //code here + let questions = []; //Now, let's say we wanted to create a quiz about JavaScript. Create three instances of Question which contain the following data //title: 'T/F: Inheritance is achieved in JavaScript through Prototypes?' @@ -35,14 +55,23 @@ //Fill in the rest of the required data as you see appropriate. //code here - + var Q1 = new Question('T/F: Inheritance is achieved in JavaScript through Prototypes?', 'T', 'T', 'easy'); + var Q2 = new Question('T/F: JavaScript is just a scripting version of Java', 'F', 'F', 'easy'); + var Q3 = new Question("T/F: In Javascript, == doesn't check 'type' but just the value - where === checks type and value", 'T','T','easy'); //Now push all of your instances of Question into the questions Array //code here + questions.push(Q1,Q2,Q3); console.log('My users Array and my questions arrray are ...'); //Now loop console.log your users array and your questions array and verify that they're both holding the right data. //code here + for(let x of quizUsers){ + console.log(x); + } + for(let y of questions){ + console.log(y); + }