From 730c48f42f01c97cf04fe13b90ab5261a5a54d1c Mon Sep 17 00:00:00 2001 From: dianageromo Date: Tue, 28 May 2019 17:31:46 +0800 Subject: [PATCH 1/6] Fill up user.json --- user.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user.json b/user.json index 4ac80a0..802040f 100644 --- a/user.json +++ b/user.json @@ -1,4 +1,4 @@ { - "name": "", - "email": "" + "name": "Diana Lyn C. Geromo", + "email": "diana.geromo@boom.camp" } From fc44ecea5db6b0166734465b0c331f7e8c4cc529 Mon Sep 17 00:00:00 2001 From: dianageromo Date: Tue, 28 May 2019 17:33:19 +0800 Subject: [PATCH 2/6] Instance Array --- instanceArray.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/instanceArray.js b/instanceArray.js index ab752ac..f2670a5 100644 --- a/instanceArray.js +++ b/instanceArray.js @@ -14,28 +14,40 @@ var User = function(name, email, pw){ //Create an Array called 'users' that will store all our instances of User. //code here + let 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 user1 = new User('Aodhan','aodhan@boom.camp','iLoveJS'); + users.push(user1); + var user2= new User('Greg','greg@boom.camp','iLovePython'); + users.push(user2); + var user3 = new User('Oscar','oscar@boom.camp','iLoveSoccer'); + users.push(user3); console.log('Aodhan\'s information is '); //Console.log all of Aodhan information //code here + console.log(users[0]); console.log('Oscar\'s information is '); //Now console.log all of Oscars information //code here - + console.log(users[2]); //Now create another instance of User using your own information and then add that to your users array. //code here - + var user4 = new User('Diana','diana@boom.camp','iLoveYou'); + users.push(user4); console.log('All my users names are '); //Now loop through your users Array and console.log every users name. //code here + for (let c=0; c Date: Tue, 28 May 2019 17:34:08 +0800 Subject: [PATCH 3/6] SayName --- sayName.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/sayName.js b/sayName.js index 6e28b51..e0e7f3f 100644 --- a/sayName.js +++ b/sayName.js @@ -1,13 +1,25 @@ -//Create a Person constructor that accepts name and age as parameters and sets those properties accordingly in the Constructor. +//Create a Person constructor that accepts name and age as +//parameters and sets those properties accordingly in the +//Constructor. //code here + var Person = function(name, age){ + this.name = name; + this.age = age; + } + - -//Now create three instances of Person with data you make up +//Now create three instances of Person with data you +//make up //code here + var person1 = new Person('Diana',20); + var person2 = new Person('Haze',21); + var person3 = new Person('Seat',22); +//Now add a sayName method on your Person class that will +// alert the name of whatever Person instance called it. - -//Now add a sayName method on your Person class that will alert the name of whatever Person instance called it. - - //code here + //code here +Person.prototype.sayName = function(){ + alert(this.name); +} From 65841f36338a2faabdc2fbc405677d4b16bb89d7 Mon Sep 17 00:00:00 2001 From: dianageromo Date: Tue, 28 May 2019 17:34:51 +0800 Subject: [PATCH 4/6] Array Property --- arrayProperty.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/arrayProperty.js b/arrayProperty.js index 2287a36..0e89927 100644 --- a/arrayProperty.js +++ b/arrayProperty.js @@ -1,5 +1,27 @@ -//Just like you can add methods to your own constructor, you can also add methods and properties to built in classes in JavaScript like Arrays and Objects. +//Just like you can add methods to your own constructor, +//you can also add methods and properties to built in classes +//in JavaScript like Arrays and Objects. -//Add a reverse method to the String 'class' so that every instance of String can call reverse and reverse itself. +//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 + + + function String(toReverse){ + this.toReverse = toReverse; + } + + + var string1 = new String("dianalyn"); + + String.prototype.reverse = function(){ + var toSplit = this.toReverse.split(''); + var toRev = toSplit.reverse(); + var toJoin = toRev.join(''); + + return toJoin; + } + + + \ No newline at end of file From d20ab2f77a29b57c1a8748b6372d7941e9ba88b6 Mon Sep 17 00:00:00 2001 From: dianageromo Date: Tue, 28 May 2019 17:35:40 +0800 Subject: [PATCH 5/6] Quiz App --- quizApp.js | 111 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/quizApp.js b/quizApp.js index 083bd6c..f67a3f3 100644 --- a/quizApp.js +++ b/quizApp.js @@ -7,42 +7,75 @@ //code here - -//Create a Question constructor that accepts title, answersArray, rightAnswer, and difficulty parameters - - //code here - - -//Create a quizUsers Array which is going to hold all of our users. - - //code here - - -//Let's say three people signed up for our service, create 3 instances of User and add each to the users Array - - //code here - - -//Create a questions Array which is going to hold all of our questions - - //code here - - -//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?' -//title: 'T/F: JavaScript is just a scripting version of Java' -//title: "T/F: In Javascript, == doesn't check 'type' but just the value - where === checks type and value" -//Fill in the rest of the required data as you see appropriate. - - //code here - - -//Now push all of your instances of Question into the questions Array - - //code here - -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 - + 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 + var 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 + var 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 user1 = new QuizUser('Aodhan','aodhan@boom.camp','iLoveJS', 0); + quizUsers.push(user1); + var user2= new QuizUser('Greg','greg@boom.camp','iLovePython', 0); + quizUsers.push(user2); + var user3 = new QuizUser('Oscar','oscar@boom.camp','iLoveSoccer', 0); + quizUsers.push(user3); + + + + //Create a questions Array which is going to hold all of our questions + + //code here + var 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?' + //title: 'T/F: JavaScript is just a scripting version of Java' + //title: "T/F: In Javascript, == doesn't check 'type' but just the value - where === checks type and value" + //Fill in the rest of the required data as you see appropriate. + + //code here + var question1 = new Question('T/F: Inheritance is achieved in JavaScript through Prototypes?', ['T', 'F'], 'F', 'easy'); + var question2 = new Question('T/F: JavaScript is just a scripting version of Java', ['T', 'F'], 'F', 'hard'); + var question3 = new Question('T/F: In Javascript, == doesn\'t check \'type\' but just the value - where === checks type and value', ['T', 'F'], 'T', 'easy'); + + //Now push all of your instances of Question into the questions Array + + //code here + questions.push(question1, question2, question3); + + + 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 c=0; c Date: Wed, 29 May 2019 10:02:09 +0800 Subject: [PATCH 6/6] Update arrayProperty.js --- arrayProperty.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/arrayProperty.js b/arrayProperty.js index 0e89927..1ccf88b 100644 --- a/arrayProperty.js +++ b/arrayProperty.js @@ -8,20 +8,27 @@ //code here - function String(toReverse){ + //code here + + function StringtoReverse(toReverse){ this.toReverse = toReverse; } + var string1 = new StringtoReverse("dianalyn"); - var string1 = new String("dianalyn"); - - String.prototype.reverse = function(){ + StringtoReverse.prototype.reverse = function(){ var toSplit = this.toReverse.split(''); - var toRev = toSplit.reverse(); - var toJoin = toRev.join(''); - return toJoin; + let temp = []; + + for (let c=toSplit.length-1; c>=0; c--){ + temp.push(toSplit[c]); + } + + var reverseString = ''; + reverseString = temp.join(''); + return reverseString; } + //console.log(string1.reverse()); - \ No newline at end of file