diff --git a/arrayProperty.js b/arrayProperty.js index 2287a36..6ddd2d2 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(){ + return this.split('').reverse().join(''); + } \ No newline at end of file diff --git a/instanceArray.js b/instanceArray.js index ab752ac..ee54ab2 100644 --- a/instanceArray.js +++ b/instanceArray.js @@ -10,32 +10,46 @@ var User = function(name, email, pw){ this.email = email; this.pw = 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 aodhan = new User("Aodhan","aodhan@boom.camp","iLoveJS"); + var greg = new User("Greg","greg@boom.camp","iLovePython"); + var oscar = new User("Oscar","oscar@boom.camp","iLoveSoccer"); + + users.push(aodhan); + users.push(greg); + users.push(oscar); console.log('Aodhan\'s information is '); //Console.log all of Aodhan information //code here + console.log(aodhan); console.log('Oscar\'s information is '); //Now console.log all of Oscars information //code here + console.log(oscar); //Now create another instance of User using your own information and then add that to your users array. //code here + var sam = new User("Sam","samuel.lopez@boom.camp","IloveMe"); + users.push(sam); console.log('All my users names are '); //Now loop through your users Array and console.log every users name. //code here + users.forEach(function(userVal){ + console.log(userVal); + }) diff --git a/quizApp.js b/quizApp.js index 083bd6c..43272c8 100644 --- a/quizApp.js +++ b/quizApp.js @@ -6,27 +6,48 @@ //Create a QuizUser constructor that accepts name, email, password, and totalScore parameters and set them appropriatly //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 sam = new QuizUser("sam", "sam@boom.boom","123", 0); + var jan = new QuizUser("pinkypat", "pinkypat@boom.boom","123", 0); + var barbs = new QuizUser("barbs", "barbs@boom.boom","123", 0); + + quizUsers.push(sam); + quizUsers.push(jan); + quizUsers.push(barbs); //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?' @@ -35,14 +56,26 @@ //Fill in the rest of the required data as you see appropriate. //code here - + var questionOne = new Question("T/F: Inheritance is achieved in JavaScript through Prototypes?",["T","F"],"T",99); + var questionTwo = new Question("T/F: Inheritance is achieved in JavaScript through Prototypes?",["T","F"],"F",99); + var questionThree = new Question("T/F: Inheritance is achieved in JavaScript through Prototypes?",["T","F"],"F",99); //Now push all of your instances of Question into the questions Array //code here + questions.push(questionOne); + questions.push(questionTwo); + questions.push(questionThree); 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 + questions.forEach(arrValue => { + console.log(arrValue) + }); + quizUsers.forEach(arrValue => { + console.log(arrValue) + }); + diff --git a/sayName.js b/sayName.js index 6e28b51..aa01c07 100644 --- a/sayName.js +++ b/sayName.js @@ -2,12 +2,24 @@ //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 barbs = new Person("JuanBarbin","69"); + var pat = new Person("PinkyPat","69"); + var sam = new Person("samsamsam","20"); //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); + } + diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 6907a75..104863d 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,10 +1,10 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); +// 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/quizAppSpec.js b/test/spec/quizAppSpec.js index 8e0c63c..a4b5d00 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,10 +1,10 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); +// 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..512e3c9 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -1,10 +1,10 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); +// 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/user.json b/user.json index 4ac80a0..be32022 100644 --- a/user.json +++ b/user.json @@ -1,4 +1,4 @@ { - "name": "", - "email": "" + "name": "Samuel A. Lopez", + "email": "samuel152018@gmail.com" }