From 7199bb7f9683dda10fdf84200cecc6abd318433d Mon Sep 17 00:00:00 2001 From: Koji Adriano Jr Date: Tue, 28 May 2019 15:47:53 +0800 Subject: [PATCH 01/18] initialized user.json --- javascript-4-prototype | 1 + user.json | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 160000 javascript-4-prototype diff --git a/javascript-4-prototype b/javascript-4-prototype new file mode 160000 index 0000000..e8c19e3 --- /dev/null +++ b/javascript-4-prototype @@ -0,0 +1 @@ +Subproject commit e8c19e345b6d4b4f09e7931baa8dae31811f2646 diff --git a/user.json b/user.json index 4ac80a0..04e3ca5 100644 --- a/user.json +++ b/user.json @@ -1,4 +1,4 @@ { - "name": "", - "email": "" -} + "name": "Rolando Koji E Adriano Jr", + "email": "rolando.adriano@boom.camp" +} \ No newline at end of file From 7e3fafdab07cfbd5a99d559d8e300af1bff13bf5 Mon Sep 17 00:00:00 2001 From: Koji Adriano Jr Date: Tue, 28 May 2019 16:10:03 +0800 Subject: [PATCH 02/18] instanceArray.js done --- instanceArray.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/instanceArray.js b/instanceArray.js index ab752ac..c7a4d27 100644 --- a/instanceArray.js +++ b/instanceArray.js @@ -5,37 +5,45 @@ 2) Oscar, oscar@boom.camp, 'iLoveSoccer' */ -var User = function(name, email, pw){ - this.name = name; - this.email = email; - this.pw = pw; +var User = function(name, email, pw) { + this.name = name; + 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(users.aodhan); console.log('Oscar\'s information is '); //Now console.log all of Oscars information - //code here +console.log(users.oscar) //Now create another instance of User using your own information and then add that to your users array. - //code here +var koji = new User('Koji', 'rolando.adriano@boom.camp', 'iLoveBoomCamp'); +users.push(koji); console.log('All my users names are '); //Now loop through your users Array and console.log every users name. - //code here +for (var x of user) { + console.log(x) +} \ No newline at end of file From aabe913eeedb18252d2b151842a15d4bff905f90 Mon Sep 17 00:00:00 2001 From: Koji Adriano Jr Date: Tue, 28 May 2019 16:22:05 +0800 Subject: [PATCH 03/18] sayName.js done --- sayName.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sayName.js b/sayName.js index 6e28b51..e8d153e 100644 --- a/sayName.js +++ b/sayName.js @@ -1,13 +1,18 @@ //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 barbs = new Person('Elijah', '20'); +var jaako = new Person('Muhamad Jaako', '35'); //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) +} \ No newline at end of file From 4312c91050d8983076acf0368151415381e9a3bd Mon Sep 17 00:00:00 2001 From: Koji Adriano Jr Date: Tue, 28 May 2019 16:34:41 +0800 Subject: [PATCH 04/18] arrayProperty.js done, sayName.js done --- arrayProperty.js | 8 ++++++-- sayName.js | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arrayProperty.js b/arrayProperty.js index 2287a36..d3ee318 100644 --- a/arrayProperty.js +++ b/arrayProperty.js @@ -1,5 +1,9 @@ //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. - - //code here \ No newline at end of file + +Person.prototype.reverseMe = function(name) { + var array = this.name; + array = array.split("").reverse().join(""); + console.log(array); +} \ No newline at end of file diff --git a/sayName.js b/sayName.js index e8d153e..bfc4a8f 100644 --- a/sayName.js +++ b/sayName.js @@ -11,6 +11,7 @@ var barbs = new Person('Elijah', '20'); var jaako = new Person('Muhamad Jaako', '35'); + //Now add a sayName method on your Person class that will alert the name of whatever Person instance called it. Person.prototype.sayName = function(name) { From 65fbf6e196f00d005a4d7491cfd9791d3f1c20cb Mon Sep 17 00:00:00 2001 From: Koji Adriano Jr Date: Tue, 28 May 2019 16:59:40 +0800 Subject: [PATCH 05/18] finished working, tasked accomplished --- arrayProperty.js | 6 +- instanceArray.js | 2 +- quizApp.js | 41 +++++-- test/spec/arrayPropertySpec.js | 64 +++++----- test/spec/quizAppSpec.js | 208 ++++++++++++++++----------------- test/spec/sayNameSpec.js | 108 ++++++++--------- 6 files changed, 213 insertions(+), 216 deletions(-) diff --git a/arrayProperty.js b/arrayProperty.js index d3ee318..6925974 100644 --- a/arrayProperty.js +++ b/arrayProperty.js @@ -2,8 +2,6 @@ //Add a reverse method to the String 'class' so that every instance of String can call reverse and reverse itself. -Person.prototype.reverseMe = function(name) { - var array = this.name; - array = array.split("").reverse().join(""); - console.log(array); +String.prototype.reverse = function() { + return this.split("").reverse().join(""); } \ No newline at end of file diff --git a/instanceArray.js b/instanceArray.js index c7a4d27..24bee45 100644 --- a/instanceArray.js +++ b/instanceArray.js @@ -44,6 +44,6 @@ users.push(koji); console.log('All my users names are '); //Now loop through your users Array and console.log every users name. -for (var x of user) { +for (var x of users) { console.log(x) } \ No newline at end of file diff --git a/quizApp.js b/quizApp.js index 083bd6c..09b9004 100644 --- a/quizApp.js +++ b/quizApp.js @@ -5,27 +5,42 @@ //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 +quizUsers.push(new QuizUser('one people', 'one@email.com', 'onepassword', 1)); +quizUsers.push(new QuizUser('two', 'two@mail.com', 'twopassword', 2)); +quizUsers.push(new QuizUser('three people', 'three@mail.com', 'threepassword', 3)); + //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,15 +49,23 @@ //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 +//code here +var firstQuestion = new Question('T/F: Inheritance is achieved in JavaScript through Prototypes?'); +var secondQuestion = new Question('T/F: JavaScript is just a scripting version of Java') +var thirdQuestion = new Question("T/F: In Javascript, == doesn't check 'type' but just the value - where === checks type and value"); //Now push all of your instances of Question into the questions Array - //code here +questions.push(firstQuestion, secondQuestion, thirdQuestion); 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 (var user_data of quizUsers) { + console.log(user_data); +} +questions.forEach(function(n) { + console.log(n); +}) \ No newline at end of file diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 6907a75..20b7086 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,43 +1,35 @@ -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'); - const path = require('path'); + // test if file is running in a node process + const fs = require('fs'); + const path = require('path'); - const filePath = path.resolve(__dirname, '../../'); // this should be the root dir - fs.readdirSync(filePath) // eval all of the js files faking how a browser would execute - .filter(path => { - if (path) { - return /\.js$/.test(path); - } else { - return false; - } - }) - .forEach(file => { - global.eval(fs.readFileSync(`${filePath}/${file}`) + ''); - }); + const filePath = path.resolve(__dirname, '../../'); // this should be the root dir + fs.readdirSync(filePath) // eval all of the js files faking how a browser would execute + .filter(path => { + if (path) { + return /\.js$/.test(path); + } else { + return false; + } + }) + .forEach(file => { + global.eval(fs.readFileSync(`${filePath}/${file}`) + ''); + }); } // Test describe('arrayProperty', function() { - describe('String', function() { - it('should have a reverse method', function() { - var str = 'Hello'; - expect(str.reverse).toBeDefined(); - expect(str.reverse).toEqual(jasmine.any(Function)); - }); - describe('reverse method', function() { - it('should reverse the string', function() { - var str = 'Hello'; - expect(str.reverse()).toEqual('olleH'); - }); + describe('String', function() { + it('should have a reverse method', function() { + var str = 'Hello'; + expect(str.reverse).toBeDefined(); + expect(str.reverse).toEqual(jasmine.any(Function)); + }); + describe('reverse method', function() { + it('should reverse the string', function() { + var str = 'Hello'; + expect(str.reverse()).toEqual('olleH'); + }); + }); }); - }); -}); +}); \ No newline at end of file diff --git a/test/spec/quizAppSpec.js b/test/spec/quizAppSpec.js index 8e0c63c..a5a6f69 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,113 +1,105 @@ -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'); - const path = require('path'); + // test if file is running in a node process + const fs = require('fs'); + const path = require('path'); - const filePath = path.resolve(__dirname, '../../'); // this should be the root dir - fs.readdirSync(filePath) // eval all of the js files faking how a browser would execute - .filter(path => { - if (path) { - return /\.js$/.test(path); - } else { - return false; - } - }) - .forEach(file => { - global.eval(fs.readFileSync(`${filePath}/${file}`) + ''); - }); + const filePath = path.resolve(__dirname, '../../'); // this should be the root dir + fs.readdirSync(filePath) // eval all of the js files faking how a browser would execute + .filter(path => { + if (path) { + return /\.js$/.test(path); + } else { + return false; + } + }) + .forEach(file => { + global.eval(fs.readFileSync(`${filePath}/${file}`) + ''); + }); } describe('quizApp', function() { - describe('QuizUser', function() { - it('should exist', function() { - expect(QuizUser).toBeDefined(); - }); - it('should be a function', function() { - expect(QuizUser).toEqual(jasmine.any(Function)); - }); - it('should return an object when called with new', function() { - var quizUser = new QuizUser('Tester', 'test', 'test', 0); - expect(quizUser).toEqual(jasmine.any(Object)); - }); - describe('return object', function() { - it('should have name, email, password, and totalScore properties', function() { - var quizUser = new QuizUser('Tester', 'test', 'test', 0); - expect(quizUser.hasOwnProperty('name')).toBe(true); - expect(quizUser.hasOwnProperty('email')).toBe(true); - expect(quizUser.hasOwnProperty('password')).toBe(true); - expect(quizUser.hasOwnProperty('totalScore')).toBe(true); - }); - }); - }); - describe('Question', function() { - it('should exist', function() { - expect(Question).toBeDefined(); - }); - it('should be a function', function() { - expect(Question).toEqual(jasmine.any(Function)); - }); - it('should return an object when called with new', function() { - var question = new Question('Tester', 'test', 'test', 0); - expect(question).toEqual(jasmine.any(Object)); - }); - describe('return object', function() { - it('should have title, answersArray, rightAnswer, and difficulty properties', function() { - var question = new Question('Tester', 'test', 'test', 0); - expect(question.hasOwnProperty('title')).toBe(true); - expect(question.hasOwnProperty('answersArray')).toBe(true); - expect(question.hasOwnProperty('rightAnswer')).toBe(true); - expect(question.hasOwnProperty('difficulty')).toBe(true); - }); - }); - }); - describe('quizUsers', function() { - it('should exist', function() { - expect(quizUsers).toBeDefined(); - }); - it('should be an array', function() { - expect(quizUsers).toEqual(jasmine.any(Array)); - }); - it('should have three items', function() { - expect(quizUsers.length).toBe(3); - }); - it('(when complete) should only contain instances of QuizUser', function() { - var areAllUsers = true; - var quizUsers = quizUsers || []; - for (var i = 0; i < quizUsers.length; i++) { - if (!users[i] instanceof QuizUser) { - areAllUsers = false; - } - } - expect(areAllUsers).toBe(true); - }); - }); - describe('questions', function() { - it('should exist', function() { - expect(questions).toBeDefined(); - }); - it('should be an array', function() { - expect(questions).toEqual(jasmine.any(Array)); - }); - it('should have three items', function() { - expect(questions.length).toBe(3); - }); - it('(when complete) should only contain instances of Question', function() { - var areAllQuestions = true; - var questions = questions || []; - for (var i = 0; i < questions.length; i++) { - if (!questions[i] instanceof Question) { - areAllQuestions = false; - } - } - expect(areAllQuestions).toBe(true); - }); - }); -}); + describe('QuizUser', function() { + it('should exist', function() { + expect(QuizUser).toBeDefined(); + }); + it('should be a function', function() { + expect(QuizUser).toEqual(jasmine.any(Function)); + }); + it('should return an object when called with new', function() { + var quizUser = new QuizUser('Tester', 'test', 'test', 0); + expect(quizUser).toEqual(jasmine.any(Object)); + }); + describe('return object', function() { + it('should have name, email, password, and totalScore properties', function() { + var quizUser = new QuizUser('Tester', 'test', 'test', 0); + expect(quizUser.hasOwnProperty('name')).toBe(true); + expect(quizUser.hasOwnProperty('email')).toBe(true); + expect(quizUser.hasOwnProperty('password')).toBe(true); + expect(quizUser.hasOwnProperty('totalScore')).toBe(true); + }); + }); + }); + describe('Question', function() { + it('should exist', function() { + expect(Question).toBeDefined(); + }); + it('should be a function', function() { + expect(Question).toEqual(jasmine.any(Function)); + }); + it('should return an object when called with new', function() { + var question = new Question('Tester', 'test', 'test', 0); + expect(question).toEqual(jasmine.any(Object)); + }); + describe('return object', function() { + it('should have title, answersArray, rightAnswer, and difficulty properties', function() { + var question = new Question('Tester', 'test', 'test', 0); + expect(question.hasOwnProperty('title')).toBe(true); + expect(question.hasOwnProperty('answersArray')).toBe(true); + expect(question.hasOwnProperty('rightAnswer')).toBe(true); + expect(question.hasOwnProperty('difficulty')).toBe(true); + }); + }); + }); + describe('quizUsers', function() { + it('should exist', function() { + expect(quizUsers).toBeDefined(); + }); + it('should be an array', function() { + expect(quizUsers).toEqual(jasmine.any(Array)); + }); + it('should have three items', function() { + expect(quizUsers.length).toBe(3); + }); + it('(when complete) should only contain instances of QuizUser', function() { + var areAllUsers = true; + var quizUsers = quizUsers || []; + for (var i = 0; i < quizUsers.length; i++) { + if (!users[i] instanceof QuizUser) { + areAllUsers = false; + } + } + expect(areAllUsers).toBe(true); + }); + }); + describe('questions', function() { + it('should exist', function() { + expect(questions).toBeDefined(); + }); + it('should be an array', function() { + expect(questions).toEqual(jasmine.any(Array)); + }); + it('should have three items', function() { + expect(questions.length).toBe(3); + }); + it('(when complete) should only contain instances of Question', function() { + var areAllQuestions = true; + var questions = questions || []; + for (var i = 0; i < questions.length; i++) { + if (!questions[i] instanceof Question) { + areAllQuestions = false; + } + } + expect(areAllQuestions).toBe(true); + }); + }); +}); \ No newline at end of file diff --git a/test/spec/sayNameSpec.js b/test/spec/sayNameSpec.js index 7fbb7bb..203390c 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -1,65 +1,57 @@ -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'); - const path = require('path'); + // test if file is running in a node process + const fs = require('fs'); + const path = require('path'); - const filePath = path.resolve(__dirname, '../../'); // this should be the root dir - fs.readdirSync(filePath) // eval all of the js files faking how a browser would execute - .filter(path => { - if (path) { - return /\.js$/.test(path); - } else { - return false; - } - }) - .forEach(file => { - global.eval(fs.readFileSync(`${filePath}/${file}`) + ''); - }); + const filePath = path.resolve(__dirname, '../../'); // this should be the root dir + fs.readdirSync(filePath) // eval all of the js files faking how a browser would execute + .filter(path => { + if (path) { + return /\.js$/.test(path); + } else { + return false; + } + }) + .forEach(file => { + global.eval(fs.readFileSync(`${filePath}/${file}`) + ''); + }); } describe('sayName', function() { - describe('Person', function() { - it('should exist', function() { - expect(Person).toBeDefined(); - }); - it('should be a function', function() { - expect(Person).toEqual(jasmine.any(Function)); - }); - it('should return an object with name and age properties when invoked with new (e.g. var person = new Person(...))', function() { - var person = new Person('Tester', 25); - expect(person.hasOwnProperty('name')).toBe(true); - expect(person.hasOwnProperty('age')).toBe(true); - }); - describe('return object', function() { - it('should be an instance of Person', function() { - var person = new Person('Tester', 25); - var isPerson = person instanceof Person; - expect(isPerson).toBe(true); - }); - it('should have access to a sayName method', function() { - var person = new Person('Tester', 25); - expect(person.sayName).toBeDefined(); - expect(person.sayName).toEqual(jasmine.any(Function)); - }); - describe('sayName', function() { - it('should alert the name of the person on which sayName is invoked', function() { - var tester = new Person('Tester', 25); - var someoneElse = new Person('Simone Elsa', 22); - var alert = spyOn(window, 'alert'); - tester.sayName(); - expect(alert).toHaveBeenCalledWith('Tester'); - someoneElse.sayName(); - expect(alert).toHaveBeenCalledWith('Simone Elsa'); + describe('Person', function() { + it('should exist', function() { + expect(Person).toBeDefined(); + }); + it('should be a function', function() { + expect(Person).toEqual(jasmine.any(Function)); + }); + it('should return an object with name and age properties when invoked with new (e.g. var person = new Person(...))', function() { + var person = new Person('Tester', 25); + expect(person.hasOwnProperty('name')).toBe(true); + expect(person.hasOwnProperty('age')).toBe(true); + }); + describe('return object', function() { + it('should be an instance of Person', function() { + var person = new Person('Tester', 25); + var isPerson = person instanceof Person; + expect(isPerson).toBe(true); + }); + it('should have access to a sayName method', function() { + var person = new Person('Tester', 25); + expect(person.sayName).toBeDefined(); + expect(person.sayName).toEqual(jasmine.any(Function)); + }); + describe('sayName', function() { + it('should alert the name of the person on which sayName is invoked', function() { + var tester = new Person('Tester', 25); + var someoneElse = new Person('Simone Elsa', 22); + var alert = spyOn(window, 'alert'); + tester.sayName(); + expect(alert).toHaveBeenCalledWith('Tester'); + someoneElse.sayName(); + expect(alert).toHaveBeenCalledWith('Simone Elsa'); + }); + }); }); - }); }); - }); -}); +}); \ No newline at end of file From cedf719f80ff951f6cfc8a6044975488c2b10880 Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 13:37:45 +0800 Subject: [PATCH 06/18] issue #48: Multiple Declaration --- test/spec/arrayPropertySpec.js | 15 ++++++++------- test/spec/instanceArraySpec.js | 14 +++++++------- test/spec/quizAppSpec.js | 15 ++++++++------- test/spec/sayNameSpec.js | 15 ++++++++------- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 6907a75..49716b5 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,10 +1,11 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); +var isNode; + +if (typeof window === 'undefined') { + global.window = {node:true} + isNode = global.window.node; +}else{ + var isNode = false; +} if (isNode()) { // test if file is running in a node process diff --git a/test/spec/instanceArraySpec.js b/test/spec/instanceArraySpec.js index 91e6170..8da349f 100644 --- a/test/spec/instanceArraySpec.js +++ b/test/spec/instanceArraySpec.js @@ -1,11 +1,11 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); +var isNode; +if (typeof window === 'undefined') { + global.window = {node:true} + isNode = global.window.node; +}else{ + var isNode = 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..d7ce51f 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,10 +1,11 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); +var isNode; + +if (typeof window === 'undefined') { + global.window = {node:true} + isNode = global.window.node; +}else{ + var isNode = 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..2d80ceb 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -1,10 +1,11 @@ -const isNode = new Function(` - try { - return this === global; - } catch (e) { - return false; - } -`); +var isNode; + +if (typeof window === 'undefined') { + global.window = {node:true} + isNode = global.window.node; +}else{ + var isNode = false; +} if (isNode()) { // test if file is running in a node process From 97383c305f1551d147386ce9b0268cbfa85d131a Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 13:40:29 +0800 Subject: [PATCH 07/18] issue #67: Replace instruction alert --- sayName.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sayName.js b/sayName.js index 6e28b51..2d4459e 100644 --- a/sayName.js +++ b/sayName.js @@ -8,6 +8,6 @@ //code here -//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 log the name of whatever Person instance called it in the console. //code here From 8c5ae4bc31813650627403654471e65ac0b387e5 Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 13:44:18 +0800 Subject: [PATCH 08/18] issue #68: Replace alert to console log --- test/spec/sayNameSpec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/spec/sayNameSpec.js b/test/spec/sayNameSpec.js index 2d80ceb..e9d3fb0 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -54,11 +54,11 @@ describe('sayName', function() { it('should alert the name of the person on which sayName is invoked', function() { var tester = new Person('Tester', 25); var someoneElse = new Person('Simone Elsa', 22); - var alert = spyOn(window, 'alert'); + var consoleLog = spyOn(console, 'log'); tester.sayName(); - expect(alert).toHaveBeenCalledWith('Tester'); + expect(consoleLog).toHaveBeenCalledWith('Tester'); someoneElse.sayName(); - expect(alert).toHaveBeenCalledWith('Simone Elsa'); + expect(consoleLog).toHaveBeenCalledWith('Simone Elsa'); }); }); }); From c1809226486b7834ea6560cbf577568f01c90b14 Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 13:50:26 +0800 Subject: [PATCH 09/18] issue #70: Add insturction to use var for declaring variables --- sayName.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sayName.js b/sayName.js index 2d4459e..b1e4be1 100644 --- a/sayName.js +++ b/sayName.js @@ -1,3 +1,5 @@ +//Note: use var for declaring variables + //Create a Person constructor that accepts name and age as parameters and sets those properties accordingly in the Constructor. //code here From e2ed91fa88bcf0b64bff871740af6f4bc9c8b99a Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 13:51:38 +0800 Subject: [PATCH 10/18] issue #71: add instruction to use var for declaring variables --- quizApp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/quizApp.js b/quizApp.js index 083bd6c..914320b 100644 --- a/quizApp.js +++ b/quizApp.js @@ -1,3 +1,4 @@ +//Note: use var for declaring variables //We're going to create the JS for a basic quiz application. //Let's think about the nature of this quiz app first. We're going to be creating lots of user objects, and we're From bfe49f3b496c2c2077672ddd36765a1b2b2e79d3 Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 13:53:06 +0800 Subject: [PATCH 11/18] issue #72: + instruction to use var --- instanceArray.js | 1 + 1 file changed, 1 insertion(+) diff --git a/instanceArray.js b/instanceArray.js index ab752ac..4dd81c2 100644 --- a/instanceArray.js +++ b/instanceArray.js @@ -1,3 +1,4 @@ +//Note: use var for declaring variables /* Your 3 Users will be the following. 0) Aodhan, aodhan@boom.camp, 'iLoveJS' From 9c0c31df027eb450989ea15695bbd917d66ffcf1 Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 13:54:12 +0800 Subject: [PATCH 12/18] issue #73: add instruction to use var for declaring variables --- arrayProperty.js | 1 + 1 file changed, 1 insertion(+) diff --git a/arrayProperty.js b/arrayProperty.js index 2287a36..a3764aa 100644 --- a/arrayProperty.js +++ b/arrayProperty.js @@ -1,3 +1,4 @@ +//Note: use var for declaring variables //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. From 25bdcc943f31daf8e220b5376afbdd8127b6bdf6 Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 14:09:04 +0800 Subject: [PATCH 13/18] Accidentally pushed the <<<< --- test/spec/arrayPropertySpec.js | 3 --- test/spec/quizAppSpec.js | 3 --- test/spec/sayNameSpec.js | 40 ---------------------------------- 3 files changed, 46 deletions(-) diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 801dd4d..058b7d6 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,5 +1,3 @@ -<<<<<<< HEAD -======= var isNode; if (typeof window === 'undefined') { @@ -9,7 +7,6 @@ if (typeof window === 'undefined') { var isNode = false; } ->>>>>>> 9c0c31df027eb450989ea15695bbd917d66ffcf1 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 4884646..27862fc 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,5 +1,3 @@ -<<<<<<< HEAD -======= var isNode; if (typeof window === 'undefined') { @@ -9,7 +7,6 @@ if (typeof window === 'undefined') { var isNode = false; } ->>>>>>> 9c0c31df027eb450989ea15695bbd917d66ffcf1 if (isNode()) { // test if file is running in a node process const fs = require('fs'); diff --git a/test/spec/sayNameSpec.js b/test/spec/sayNameSpec.js index 535c80a..6f35bf8 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -1,5 +1,3 @@ -<<<<<<< HEAD -======= var isNode; if (typeof window === 'undefined') { @@ -9,7 +7,6 @@ if (typeof window === 'undefined') { var isNode = false; } ->>>>>>> 9c0c31df027eb450989ea15695bbd917d66ffcf1 if (isNode()) { // test if file is running in a node process const fs = require('fs'); @@ -30,42 +27,6 @@ if (isNode()) { } describe('sayName', function() { -<<<<<<< HEAD - describe('Person', function() { - it('should exist', function() { - expect(Person).toBeDefined(); - }); - it('should be a function', function() { - expect(Person).toEqual(jasmine.any(Function)); - }); - it('should return an object with name and age properties when invoked with new (e.g. var person = new Person(...))', function() { - var person = new Person('Tester', 25); - expect(person.hasOwnProperty('name')).toBe(true); - expect(person.hasOwnProperty('age')).toBe(true); - }); - describe('return object', function() { - it('should be an instance of Person', function() { - var person = new Person('Tester', 25); - var isPerson = person instanceof Person; - expect(isPerson).toBe(true); - }); - it('should have access to a sayName method', function() { - var person = new Person('Tester', 25); - expect(person.sayName).toBeDefined(); - expect(person.sayName).toEqual(jasmine.any(Function)); - }); - describe('sayName', function() { - it('should alert the name of the person on which sayName is invoked', function() { - var tester = new Person('Tester', 25); - var someoneElse = new Person('Simone Elsa', 22); - var alert = spyOn(window, 'alert'); - tester.sayName(); - expect(alert).toHaveBeenCalledWith('Tester'); - someoneElse.sayName(); - expect(alert).toHaveBeenCalledWith('Simone Elsa'); - }); - }); -======= describe('Person', function() { it('should exist', function() { expect(Person).toBeDefined(); @@ -98,7 +59,6 @@ describe('sayName', function() { expect(consoleLog).toHaveBeenCalledWith('Tester'); someoneElse.sayName(); expect(consoleLog).toHaveBeenCalledWith('Simone Elsa'); ->>>>>>> 9c0c31df027eb450989ea15695bbd917d66ffcf1 }); }); }); \ No newline at end of file From 94bfb505d9b0e141dbab6d1d1e87bc721300289c Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 14:16:32 +0800 Subject: [PATCH 14/18] Update on issue #48 --- test/spec/arrayPropertySpec.js | 8 +------- test/spec/instanceArraySpec.js | 9 +-------- test/spec/quizAppSpec.js | 9 +-------- test/spec/sayNameSpec.js | 9 +-------- 4 files changed, 4 insertions(+), 31 deletions(-) diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 49716b5..3483b9f 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,11 +1,5 @@ -var isNode; -if (typeof window === 'undefined') { - global.window = {node:true} - isNode = global.window.node; -}else{ - var isNode = false; -} +var isNode = ( typeof window === 'undefined' ) ? true : false ; if (isNode()) { // test if file is running in a node process diff --git a/test/spec/instanceArraySpec.js b/test/spec/instanceArraySpec.js index 8da349f..56492c6 100644 --- a/test/spec/instanceArraySpec.js +++ b/test/spec/instanceArraySpec.js @@ -1,11 +1,4 @@ -var isNode; - -if (typeof window === 'undefined') { - global.window = {node:true} - isNode = global.window.node; -}else{ - var isNode = false; -} +var isNode = ( typeof window === 'undefined' ) ? true : 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 d7ce51f..35b7fa6 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,11 +1,4 @@ -var isNode; - -if (typeof window === 'undefined') { - global.window = {node:true} - isNode = global.window.node; -}else{ - var isNode = false; -} +var isNode = ( typeof window === 'undefined' ) ? true : 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 e9d3fb0..21b3fdc 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -1,11 +1,4 @@ -var isNode; - -if (typeof window === 'undefined') { - global.window = {node:true} - isNode = global.window.node; -}else{ - var isNode = false; -} +var isNode = ( typeof window === 'undefined' ) ? true : false ; if (isNode()) { // test if file is running in a node process From 71c467975aed9a2a11d9b0ac5f5d1bfe42163527 Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 14:37:55 +0800 Subject: [PATCH 15/18] Update on bug with sayName.spec --- test/spec/sayNameSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/sayNameSpec.js b/test/spec/sayNameSpec.js index 21b3fdc..c73fb9f 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -56,4 +56,4 @@ describe('sayName', function() { }); }); }); -}); +}); //change was here From 4f10f3c8677ca9a51387d881662ba9ae2e9a164b Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 14:54:21 +0800 Subject: [PATCH 16/18] Issue#48, fix changed isNode() --> isNode --- test/spec/arrayPropertySpec.js | 2 +- test/spec/instanceArraySpec.js | 2 +- test/spec/quizAppSpec.js | 2 +- test/spec/sayNameSpec.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 3483b9f..f6e24f8 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,7 +1,7 @@ var isNode = ( typeof window === 'undefined' ) ? true : false ; -if (isNode()) { +if (isNode) { // test if file is running in a node process const fs = require('fs'); const path = require('path'); diff --git a/test/spec/instanceArraySpec.js b/test/spec/instanceArraySpec.js index 56492c6..0794199 100644 --- a/test/spec/instanceArraySpec.js +++ b/test/spec/instanceArraySpec.js @@ -1,5 +1,5 @@ var isNode = ( typeof window === 'undefined' ) ? true : false ; -if (isNode()) { +if (isNode) { // test if file is running in a node process const fs = require('fs'); const path = require('path'); diff --git a/test/spec/quizAppSpec.js b/test/spec/quizAppSpec.js index 35b7fa6..90e04d3 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,6 +1,6 @@ var isNode = ( typeof window === 'undefined' ) ? true : false ; -if (isNode()) { +if (isNode) { // test if file is running in a node process const fs = require('fs'); const path = require('path'); diff --git a/test/spec/sayNameSpec.js b/test/spec/sayNameSpec.js index c73fb9f..9d54307 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -1,6 +1,6 @@ var isNode = ( typeof window === 'undefined' ) ? true : false ; -if (isNode()) { +if (isNode) { // test if file is running in a node process const fs = require('fs'); const path = require('path'); From c28087845eb6e9a3975ef00712ea71baebe42819 Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 14:58:32 +0800 Subject: [PATCH 17/18] test subject #3 fix --- test/spec/arrayPropertySpec.js | 7 ------- test/spec/quizAppSpec.js | 7 ------- 2 files changed, 14 deletions(-) diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 22e857c..8c72797 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,17 +1,10 @@ var isNode = ( typeof window === 'undefined' ) ? true : false ; -<<<<<<< HEAD -if (isNode()) { - // test if file is running in a node process - const fs = require('fs'); - const path = require('path'); -======= if (isNode) { // test if file is running in a node process const fs = require('fs'); const path = require('path'); ->>>>>>> 4f10f3c8677ca9a51387d881662ba9ae2e9a164b const filePath = path.resolve(__dirname, '../../'); // this should be the root dir fs.readdirSync(filePath) // eval all of the js files faking how a browser would execute diff --git a/test/spec/quizAppSpec.js b/test/spec/quizAppSpec.js index a1f3d8a..be415df 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,16 +1,9 @@ var isNode = ( typeof window === 'undefined' ) ? true : false ; -<<<<<<< HEAD -if (isNode()) { - // test if file is running in a node process - const fs = require('fs'); - const path = require('path'); -======= if (isNode) { // test if file is running in a node process const fs = require('fs'); const path = require('path'); ->>>>>>> 4f10f3c8677ca9a51387d881662ba9ae2e9a164b const filePath = path.resolve(__dirname, '../../'); // this should be the root dir fs.readdirSync(filePath) // eval all of the js files faking how a browser would execute From da9259300121424da0adca92a13de8b2997d089f Mon Sep 17 00:00:00 2001 From: kojiadrianojr Date: Fri, 18 Oct 2019 15:00:48 +0800 Subject: [PATCH 18/18] test subject #4 --- test/spec/arrayPropertySpec.js | 2 +- test/spec/instanceArraySpec.js | 2 +- test/spec/quizAppSpec.js | 2 +- test/spec/sayNameSpec.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/spec/arrayPropertySpec.js b/test/spec/arrayPropertySpec.js index 8c72797..7682377 100644 --- a/test/spec/arrayPropertySpec.js +++ b/test/spec/arrayPropertySpec.js @@ -1,5 +1,5 @@ -var isNode = ( typeof window === 'undefined' ) ? true : false ; +var isNode = ( typeof window === 'undefined' ) if (isNode) { // test if file is running in a node process diff --git a/test/spec/instanceArraySpec.js b/test/spec/instanceArraySpec.js index 0794199..bcd1df2 100644 --- a/test/spec/instanceArraySpec.js +++ b/test/spec/instanceArraySpec.js @@ -1,4 +1,4 @@ -var isNode = ( typeof window === 'undefined' ) ? true : false ; +var isNode = ( typeof window === 'undefined' ) 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 be415df..d49498d 100644 --- a/test/spec/quizAppSpec.js +++ b/test/spec/quizAppSpec.js @@ -1,4 +1,4 @@ -var isNode = ( typeof window === 'undefined' ) ? true : false ; +var isNode = ( typeof window === 'undefined' ) if (isNode) { // test if file is running in a node process diff --git a/test/spec/sayNameSpec.js b/test/spec/sayNameSpec.js index 1ea38a8..f86f291 100644 --- a/test/spec/sayNameSpec.js +++ b/test/spec/sayNameSpec.js @@ -1,4 +1,4 @@ -var isNode = ( typeof window === 'undefined' ) ? true : false ; +var isNode = ( typeof window === 'undefined' ) if (isNode) { // test if file is running in a node process