From fc33f3dd4890d4575b72a726395033d1dcc3f4ad Mon Sep 17 00:00:00 2001 From: ogbry Date: Tue, 28 May 2019 17:03:02 +0800 Subject: [PATCH] submission --- instanceArray.js | 21 ++++++++++++++++----- quizApp.js | 31 +++++++++++++++++++++++++------ sayName.js | 14 +++++++++++--- user.json | 4 ++-- 4 files changed, 54 insertions(+), 16 deletions(-) diff --git a/instanceArray.js b/instanceArray.js index ab752ac..ffd9148 100644 --- a/instanceArray.js +++ b/instanceArray.js @@ -14,28 +14,39 @@ 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 + users0 = new User('Aodhan' , 'aodhan@boom.camp' , 'iLoveJS'); + users1 = new User('Greg' , 'greg@boom.camp' , 'iLovePython'); + users2 = new User('Oscar' , 'oscar@boom.camp' , 'iLoveSoccer'); + + users.push(users0, users1, users2); + + 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 +users3 = new User('Bryan' , 'bryan.alfuente@boom.camp' , 'iLoveBooty'); +users.push(users3); console.log('All my users names are '); //Now loop through your users Array and console.log every users name. - //code here +users.forEach(element => { + console.log(element.name); +}); \ No newline at end of file diff --git a/quizApp.js b/quizApp.js index 083bd6c..e39d068 100644 --- a/quizApp.js +++ b/quizApp.js @@ -5,27 +5,43 @@ //Create a QuizUser constructor that accepts name, email, password, and totalScore parameters and set them appropriatly - //code here + function QuizUser(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 + function Question(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 + user1 = new QuizUser ('Jude' , 'jude@gmail.com' , 'ahsarado', 0 ); + user2 = new QuizUser ('Manly' , 'manly@gmail.com' , 'manlyk', 0 ); + user3 = new QuizUser ('Navas' , 'navas@gmail.com' , 'navasv', 0 ); + + quizUsers.push(user1, user2, 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 @@ -34,8 +50,11 @@ //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 + questions1 = new Question ('title: T/F: Inheritance is achieved in JavaScript through Prototypes?'); + question2 = new Question ('title: T/F: Inheritance is achieved in JavaScript through Prototypes?'); + question3 = new Question ('title: T/F: Inheritance is achieved in JavaScript through Prototypes?'); + questions.push(questions1, question2, question3); //Now push all of your instances of Question into the questions Array diff --git a/sayName.js b/sayName.js index 6e28b51..30b984d 100644 --- a/sayName.js +++ b/sayName.js @@ -1,13 +1,21 @@ //Create a Person constructor that accepts name and age as parameters and sets those properties accordingly in the Constructor. - //code here + function Person(name, age){ + this.name = name; + this.age = age; + } //Now create three instances of Person with data you make up - //code here + var Gay = new Person('Jude', 22); + var Homo = new Person('Manly', 21); + var Bading = new Person('Navas', 23); //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(){ + alert(this.name); + } +console.log(Person); \ No newline at end of file diff --git a/user.json b/user.json index 4ac80a0..bb5fcd1 100644 --- a/user.json +++ b/user.json @@ -1,4 +1,4 @@ { - "name": "", - "email": "" + "name": "Bryan A. Alfuente", + "email": "bryan.alfuente@boom.camp" }