-
Notifications
You must be signed in to change notification settings - Fork 83
adding testing exercises #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
elie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch your indentation, make sure you're using 2 spaces. Keep it up!
lodash_exercise/lodash.js
Outdated
| //_.drop([1, 2, 3]); | ||
| // => [2, 3] | ||
| function drop(array, n){ | ||
| if (n === undefined){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch your indentation - 2 spaces please!
lodash_exercise/lodash.js
Outdated
|
|
||
|
|
||
| function fromPairs(array) { | ||
| if(array.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better on the indentation front!
lodash_exercise/lodash.js
Outdated
| } | ||
|
|
||
| function head(array){ | ||
| return array.shift(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch your indentation - 2 spaces please!
lodash_exercise/lodash.js
Outdated
| } | ||
|
|
||
| function take(array, num){ | ||
| var newArr = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch your indentation - 2 spaces please!
lodash_exercise/lodash.js
Outdated
| function takeRight(array, num){ | ||
| if (num === 0) { | ||
| return []; | ||
| } else if (num >= array.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch your indentation - this stuff will drive developers crazy :)
lodash_exercise/lodash.js
Outdated
| return (input.indexOf(value) != -1); | ||
| } | ||
| } else if (typeof input === "string") { | ||
| return (input.indexOf(value) != -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for () here
lodash_exercise/lodash.js
Outdated
| } | ||
|
|
||
| function sample(arr){ | ||
| return arr[Math.floor(Math.random() * (arr.length))]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for () around arr.length
| //contains(nestedObject, 44) // true | ||
| //contains(nestedObject, "foo") // false | ||
| function contains(obj, value) { | ||
| return collectStrings(obj).indexOf(value) !== -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Try to do this without using your collectStrings method :)
testing_exercise/testingSpec.js
Outdated
|
|
||
| // WRITE YOUR TESTS HERE! | ||
| describe("replaceWith", function () { | ||
| it("replaces a capital with a capital", function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch your indentation - 2 spaces please.
| }); | ||
| //Write a function called mergeObjects which takes in two objects and return an object with the keys and values combined. If the second parameter has the same key - it should override first one. There is a built in function called Object.assign - research it, but do not use it, try to do this on your own! | ||
| describe("mergeObjects", function () { | ||
| it("returns an object with combined keys and values", function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation - 2 spaces please!
elie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep it up - try to finish these lodash exercises!
| var name = "Josie" | ||
| console.log("When " + name + " comes home, so good") | ||
| console.log(`When ${name} comes home, so good`); | ||
| //Steely Dan? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you know it!
| @@ -1,15 +1,88 @@ | |||
| window.addEventListener("load", function() { | |||
| //flow of what needs to happen: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start and your code looks clean so far. Try to add the seconds timer and stop the game after 30 seconds have passed.
|
|
||
|
|
||
| String.prototype.reverse = function () { | ||
| var result = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job using an array here.
| Function.prototype.bind = function (thisArg, ...outerArgs){ | ||
| var _this = this; | ||
| return function (...innerArgs) { | ||
| return _this.apply(thisArg, outerArgs.concat(innerArgs)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| } | ||
| } | ||
| } | ||
| ///yeah still need clarification on how this works ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you want me to go over this with you. Looks like you go it right.
| } | ||
| } | ||
|
|
||
| function sayHi() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could change this to:
var obj = {
fullName: "Harry Potter",
person: {
sayHi: function(){
return "This person's name is " + this.fullName
}
}
}
obj.person.sayHi = obj.person.sayHi.bind(obj);
That way, you preserve the structure.
| } | ||
| var person2 = { | ||
| fullName: "Harry Potter", | ||
| sayHi: function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be simplified more:
var person2 = {
fullName: "Harry Potter",
sayHi() {
setTimeout( () => console.log(`Your name is ${this.fullName}`), 1000)
}
}
| } | ||
|
|
||
| function inRange(){ | ||
| function inRange() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to work on the rest of these when you get a chance.
| Function.prototype.bind = function (thisArg, ...outerArgs){ | ||
| var _this = this; | ||
| return function (...innerArgs) { | ||
| return _this.apply(thisArg, outerArgs.concat(innerArgs)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
Hey Sarah, have you made progress on the hacker snooze app? I didn't see any changes related to that in your PR |
No description provided.