Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
993239d
finished testing
toChaim Aug 1, 2017
31b4be4
fix some tests and my progress so far.
toChaim Aug 3, 2017
4fc875b
a little more done.
toChaim Aug 3, 2017
f401746
fix sort on mergeArrays and remove unesercery arguments from callback…
toChaim Aug 3, 2017
551ac19
inRange done
toChaim Aug 3, 2017
de0972b
refactor and improve inRange. Now it the non inclusive end is right f…
toChaim Aug 3, 2017
8166895
finish lodash
toChaim Aug 3, 2017
14ac495
game working, responsive working.
toChaim Aug 4, 2017
32904c3
2015 exersiexercises
toChaim Aug 5, 2017
ba3afd8
half finished.
toChaim Aug 7, 2017
633ce47
functioning is fine. styleing needs work.
toChaim Aug 8, 2017
839272f
minore improvments.
toChaim Aug 8, 2017
b65ff9d
fix favoriets filter bug
toChaim Aug 8, 2017
9db7da1
first commit on new progject
toChaim Aug 9, 2017
acf4726
working on using login
toChaim Aug 9, 2017
fe30029
got get of favoriets array working. improve login click.
toChaim Aug 9, 2017
380ef76
start on callApplyBind problems
toChaim Aug 9, 2017
fb38d6d
finished tests for guessingGame and passed tests.
toChaim Aug 10, 2017
05e9cce
finish part 1 and 2 original.
toChaim Aug 10, 2017
15056d5
Merge branch 'master' of https://github.com/rithmschool/intermediate_…
toChaim Aug 10, 2017
f4d98df
finish part 1 & 2
toChaim Aug 10, 2017
ed8a7e3
tic,tac,toe working
toChaim Aug 11, 2017
fd0df58
refactoring tic tac toe
toChaim Aug 11, 2017
c70ee42
fix message. Calling myself done.
toChaim Aug 11, 2017
854a393
refactor hacker snooze. Almost Done
toChaim Aug 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions testing_exercise/testing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function replaceWith(str, target, replacement){
return str
.split('')
.map(function(v,i,a){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small thing, but if you're not using the other arguments i and a, you don't need to include them in the callback. your callback can just be a function of a single parameter.

if(v === target) return replacement;
else return v;
}).join('');
}

function expand(arr, num) {
var a = [];

for(let i = 0; i < num; i++){
a = a.concat(arr);
}

return a;
}

function acceptNumbersOnly(...args) {
for(let a of args){
if(typeof a !== 'number' || isNaN(a)){
return false;
}
}

return true;
}

function mergeArrays(arr1, arr2) {
return arr1.concat(arr2).sort();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one gotcha to be aware of with sort - it won't sort numbers correctly! The default sort in JavaScript is alphabetical, so for example:

[23,1,4].sort() // [1, 23, 4]

The example doesn't catch this.

To fix this, you can pass in a comparator to the sort function telling it how it should sort. reference

}

function mergeObjects(...args) {
return args.reduce(function(t,v,i,a){
Object.keys(v).forEach(function(sv, si, sa){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above - your callbacks here only need to reference the variables you're actually using.

t[sv] = v[sv];
});
return t;
},{});
}
96 changes: 95 additions & 1 deletion testing_exercise/testingSpec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,97 @@
var expect = chai.expect;

// WRITE YOUR TESTS HERE!
describe('This will test the replaceWith function', function(){

it('replaceWith should be a function', function() {
expect(typeof replaceWith).to.equal('function');
});
it('replaceWith should return correct values', function () {
expect(replaceWith("awesome", "e", "z")).to.equal("awzsomz");
expect(replaceWith("Foo", "F", "B")).to.equal("Boo");
});
it('replaceWith should be case sensitive', function () {
expect(replaceWith("awesomE", "e", "z")).to.equal("awzsomE");
expect(replaceWith("Foo", "f", "B")).to.equal("Foo");
expect(replaceWith("ffFFfFB", "f", "B")).to.equal("BBFFBFB");
});

});

describe('This will test the expand function', function(){

it('expand should be a function', function() {
expect(typeof expand).to.equal('function');
});
it('expand should return correct values', function () {
expect(expand([1,2,3],3)).to.deep.equal([1,2,3,1,2,3,1,2,3]);
expect(expand(["foo", "test"],1)).to.deep.equal(["foo","test"]);
expect(expand(["foo", "test"],0)).to.deep.equal([]);
});

});

describe('This will test the acceptNumbersOnly function', function(){

it('expand should be a function', function() {
expect(typeof acceptNumbersOnly).to.equal('function');
});

it('acceptNumbersOnly should return correct values', function () {
expect(acceptNumbersOnly(1,"foo")).to.equal(false);
expect(acceptNumbersOnly(1,2,3,4,5,6,7)).to.equal(true);
expect(acceptNumbersOnly(1)).to.equal(true);
});

it('acceptNumbersOnly should deal with objects input', function () {
expect(acceptNumbersOnly([])).to.equal(false);
expect(acceptNumbersOnly({})).to.equal(false);
});

it('acceptNumbersOnly should deal with strings input', function () {
expect(acceptNumbersOnly('')).to.equal(false);
expect(acceptNumbersOnly('5')).to.equal(false);
});

it('acceptNumbersOnly should deal with null input', function () {
expect(acceptNumbersOnly(null)).to.equal(false);
});

it('acceptNumbersOnly should deal with NaN input', function () {
expect(acceptNumbersOnly(NaN)).to.equal(false);
});
});

describe('This will test the mergeArrays function', function(){

it('mergeArrays should be a function', function() {
expect(typeof mergeArrays).to.equal('function');
});
it('mergeArrays should return correct values', function () {
expect(mergeArrays([2,1],[3,4])).to.deep.equal([1,2,3,4]);
});

});

describe('This will test the mergeObjects function', function(){
var obj1= {
name: "Foo",
num: 33
}
var obj2 = {
test: "thing",
num: 55
}
var obj12 = {
name: "Foo",
test: "thing",
num: 55
}

it('mergeObjects should be a function', function() {
expect(typeof mergeObjects).to.equal('function');
});
it('mergeObjects should return correct values', function () {
expect(mergeObjects(obj1, obj2)).to.deep.equal(obj12);
});

});