diff --git a/ajax_with_jquery_exercise/index.html b/ajax_with_jquery_exercise/index.html new file mode 100644 index 00000000..442667f9 --- /dev/null +++ b/ajax_with_jquery_exercise/index.html @@ -0,0 +1,93 @@ + + + + + Hacker News Clone + + + + + + + + + + + + + + + + + + + +
+
+ +
+

Hack or Snooze

+
+
+ Log In +
+
+ Sign Up +
+ + +
+ +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+ + +
+ +
+ +
+ + +
+
+
+ +
    +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + diff --git a/ajax_with_jquery_exercise/main.js b/ajax_with_jquery_exercise/main.js new file mode 100644 index 00000000..679e21cb --- /dev/null +++ b/ajax_with_jquery_exercise/main.js @@ -0,0 +1,167 @@ +$(function() { + + $("form").on("submit", function(e) { + e.preventDefault(); + + topStories() + signUpUser() + + // var $newTitle = $('#newTitle').val() + // var $newURL = $('#urlToAdd').val() + // var icon = "" + // var $newLi = $("
  • " + icon + " " + $newTitle + " " + $newURL + "
  • "); + // $("ol").append($newLi); + + // $newTitle.val(""); + // $newURL.val(""); + }); + + + $('ol').click(function(event){ + $(event.target).toggleClass('glyphicon-star-empty glyphicon-star'); + + addToFavorites() + + + }); + + $("btnFavs").on("click", function(e) { + e.preventDefault(); + + addToFavorites(); + retrieveFavorites(); + + } ) + + +//----------------------------------------------------------------------- + // Create the Top Stories List + var icon = "" + + function topStories() { + $.get( "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty", function( data ) { + var arrIDs = []; + //create array of Top 20 story IDs, that push a complete url to the array + for (var i = 0; i < 20; i++) { + arrIDs.push("https://hacker-news.firebaseio.com/v0/item/" + data[i] + ".json") + } + //use the url's from above to run another get funtion to get the details for each story ID + for (var i = 0; i < arrIDs.length; i++) { + $.get(arrIDs[i]) + .then(function (data) { + // $('ol').append("
  • " + icon + "
    " + data.title + "
    (" + data.url + ")
  • ") + $('ol').append("
  • " + icon + "
    " + data.title + "
  • ") + + }) + .fail(function(err) { + console.log(err); + }); + } + }) + } + + + + var $email = $('#email').val(); + // console.log($email); + var $password = $('#password').val(); + // console.log($password); + var authKy = ""; + + + function signUpUser(email, password) { + + $.ajax({ + method: "POST", + headers: { + "Content-Type": "application/json" + }, + url: "https://hn-favorites.herokuapp.com/signup", + data: JSON.stringify({ + email: $email, + password: $password + }) + }) + .then(function(data) { authKy = (data.auth_token) }) + .fail(err => console.warn(err)) + + } + + function logInUser(email, password) { + $.ajax({ + method: "POST", + headers: { + "Content-Type": "application/json" + }, + url: "https://hn-favorites.herokuapp.com/signup", + data: JSON.stringify({ + email: $email, + password: $password + }) + }) + .then(function(data) { authKy = (data.auth_token)}) + .fail(err => console.warn(err)) + } + +//If a story is clicked, do addToFavorites() function that will add it to the favorites list + function addToFavorites() { + $.ajax({ + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": authKy + }, + url: "https://hn-favorites.herokuapp.com/stories.json", + data: JSON.stringify({ + hacker_news_story: { + by: "aj", + story_id: "123", + title: "Test story", + url: "abc.com" + } + }) + }) + .then(function(data) { console.log(data) }) + .fail(err => console.warn(err)) + } + + function retrieveFavorites() { + $.ajax({ + method: "GET", + headers: { + "Content-Type": "application/json", + "Authorization": authKy + }, + url: "https://hn-favorites.herokuapp.com/stories.json", + data: JSON.stringify({ + hacker_news_story: { + by: "aj", + story_id: "123", + title: "Test story", + url: "abc.com" + } + }) + }) + .then(function(data) { console.log("fav's response: " + data) }) + .fail(err => console.warn(err)) + } + + + +}); + + + + + + + + + + + + + + + + diff --git a/call_apply_bind_exercise/callApplyBind.js b/call_apply_bind_exercise/callApplyBind.js index e69de29b..673fbc96 100644 --- a/call_apply_bind_exercise/callApplyBind.js +++ b/call_apply_bind_exercise/callApplyBind.js @@ -0,0 +1,66 @@ +function sumEvenArguments() { + var result = 0; + for(var i = 0; i < arguments.length; i++) { + if(arguments[i] % 2 === 0) { + result += arguments[i]; + } + } + return result +} + + +function arrayFrom() { + var finalArr = []; + for(var i = 0; i < arguments.length; i++) { + finalArr.push(arguments[i]); + } + return finalArr; +} + +function invokeMax(fn, maxAmount) { + + var counter = 0; + + return function() { + counter++; + + if(counter > maxAmount) { + return "Maxed Out!" + } else { + return fn.apply(this, [].slice.call(arguments)) + } + } +} + + +var addOnlyThreeTimes = invokeMax(add,3); +addOnlyThreeTimes(1,2); // 3 +addOnlyThreeTimes(2,2); // 4 +addOnlyThreeTimes(1,2); // 3 +addOnlyThreeTimes(1,2); // "Maxed Out!" + + + +function guessingGame(amount) { + + var answer = Math.round(Math.random()*10) + var guesses = 0; + + + return function(guess) { + if(guesses < amount) { + guesses++ + } else { + return "Game Over!" + } + + if(guess === answer){ + return "You got it!"; + } else if(guess > answer) { + return "You're too high!"; + } else if(guess < answer) { + return "You're too low!" + } + + } +} \ No newline at end of file diff --git a/call_apply_bind_exercise/readme.md b/call_apply_bind_exercise/readme.md index cbc3cd03..38a30123 100644 --- a/call_apply_bind_exercise/readme.md +++ b/call_apply_bind_exercise/readme.md @@ -5,17 +5,15 @@ Fix the following code: ```javascript var obj = { fullName: "Harry Potter", - person: { - sayHi: function(){ - return "This person's name is " + this.fullName - } + sayHi: function(){ + return "This person's name is " + this.fullName; } } ``` - List two examples of "array-like-objects" that we have seen. - - - - + - arguments + - sets ### Functions to write: diff --git a/canvas_exercise/.DS_Store b/canvas_exercise/.DS_Store new file mode 100644 index 00000000..c8afd7dd Binary files /dev/null and b/canvas_exercise/.DS_Store differ diff --git a/canvas_exercise/shapes_game/index.js b/canvas_exercise/shapes_game/index.js index 0de5f18a..e17c8dd7 100644 --- a/canvas_exercise/shapes_game/index.js +++ b/canvas_exercise/shapes_game/index.js @@ -1,22 +1,10 @@ window.addEventListener("load", function() { - function clear(ctx, width, heigt) { - } - - function drawRandomShape(ctx, width, height) { - } - - function drawGameStartText(ctx, width, height, score) { - } - - function restartGame(ctx, width, height) { - } - var canvas = document.getElementById("shapes-game"), height = canvas.scrollHeight, width = canvas.scrollWidth, - gameOn = false, - expectedKey = undefined, + // gameOn = false, + // expectedKey = undefined, ctx = canvas.getContext('2d'), // white triangle = up, red square = down, // red triangle = left, white square = right @@ -26,11 +14,165 @@ window.addEventListener("load", function() { seconds = 3, intervalId; - canvas.width = width; - canvas.height = height; + canvas.width = width; + canvas.height = height; + + var shapeVal = 0; + var totalScore = 0; + var timerCountDown = 1; + var keyCodes = [37, 38, 39, 40]; + + +//------------------------------------------------------------------- +//Opening screen +drawStartText(); + +//------------------------------------------------------------------- +//Start Game + function startGame() { + clear(); //clear the canvas + drawRandomShape(); //add a random shape track scoring + countDown(); //start timer countdown + } + +//------------------------------------------------------------------- + +function drawStartText() { + ctx.font = '40px serif'; + ctx.fillStyle = 'orange'; + ctx.fillText('Press the Space Bar to start a new game', 60, 340); +} + +function drawStartTextAfterGame() { + ctx.font = '40px serif'; + ctx.fillStyle = 'orange'; + ctx.fillText('Game Over', 290, 340); + ctx.fillText('Press the Space Bar to start a new game', 60, 380); +} + +//To start game, listen for spacebar keypress +document.body.onkeypress = function(e){ + if(e.keyCode === 32){ + startGame(); + } +} + +function clear() { + ctx.clearRect(0, 0, height, width); +} + + function drawRandomShape() { + //draw random image + var randomImg = Math.floor(Math.random()*(5-1)+1); + switch(randomImg) { + case 1: + drawRedSquare() + break; + case 2: + drawWhiteSquare() + break; + case 3: + drawRedTriangle() + break; + case 4: + drawWhiteTriangle() + } + //compare image's value to keycode value, and calculate scoring + document.body.onkeydown = function(e){ + if(e.keyCode == shapeVal) { + totalScore++ + scoreSpan.innerHTML = totalScore; + clear() + drawRandomShape() + } else if(keyCodes.includes(e.keyCode)) { + totalScore-- + scoreSpan.innerHTML = totalScore; + clear() + drawRandomShape() + } + } + } + + function randomCoordinate() { + return Math.floor(Math.random()*(600-100)+100); + } + +//------------------------------------------------- + +function countDown() { + timerCountDown = 30; + var intervalID = setInterval(function () { + timerSpan.innerHTML = timerCountDown; + timerCountDown-- ; + if(timerCountDown < 1) { + clearInterval(intervalID); //if i is 0, then stop the interval + endGame(); + totalScore = 0; + if (event.onkeypress) { + event.preventDefault(); + } + } + }, 1000); +} + + +function endGame() { + clear(); + drawStartTextAfterGame(); + timerSpan.innerHTML = "0"; + scoreSpan.innerHTML = totalScore+1; + +} + + +//------------------------------------------------------------------- +//shape functions + function drawRedSquare() { + shapeVal = 40 + var upperLeftX = randomCoordinate() + var upperLeftY = randomCoordinate() + var width = 100; + var height = 100; + ctx.fillStyle = "red"; + ctx.fillRect(upperLeftX, upperLeftY, width, height); + } + + function drawWhiteSquare() { + shapeVal = 39 + var upperLeftX = randomCoordinate() + var upperLeftY = randomCoordinate() + var width = 100; + var height = 100; + ctx.fillStyle = "white"; + ctx.fillRect(upperLeftX, upperLeftY, width, height); + } + +function drawWhiteTriangle() { + shapeVal = 38 + var xCoord = randomCoordinate() + var yCoord = randomCoordinate() + var canvas = document.getElementById('shapes-game'); + ctx.fillStyle = "white"; + ctx.beginPath(); + ctx.moveTo(xCoord, yCoord); + ctx.lineTo(xCoord, yCoord + 100); + ctx.lineTo(xCoord + 100, yCoord + 100); + ctx.fill(); +} + +function drawRedTriangle() { + shapeVal = 37 + var xCoord = randomCoordinate() + var yCoord = randomCoordinate() + var canvas = document.getElementById('shapes-game'); + ctx.fillStyle = "red"; + ctx.beginPath(); + ctx.moveTo(xCoord, yCoord); + ctx.lineTo(xCoord, yCoord + 100); + ctx.lineTo(xCoord + 100, yCoord + 100); + ctx.fill(); +} + - document.addEventListener("keyup", function() { - - }); }); diff --git a/canvas_exercise/shapes_game/styles.css b/canvas_exercise/shapes_game/styles.css index cbe4fa83..f66944ad 100644 --- a/canvas_exercise/shapes_game/styles.css +++ b/canvas_exercise/shapes_game/styles.css @@ -5,6 +5,7 @@ body { #shapes-game { border: 4px solid grey; background-color: black; + } .canvas-container { diff --git a/jquery_exercise/index.html b/jquery_exercise/index.html new file mode 100644 index 00000000..8f4ffc17 --- /dev/null +++ b/jquery_exercise/index.html @@ -0,0 +1,85 @@ + + + + + Hacker News Clone + + + + + + + + + + + + + + + + + + + +
    +
    +
    +

    Hack or Snooze

    +
    +
    + submit +
    +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + + +
    +
    +
    + +
      +
    +
    +
    +
    + +
    + + + + + + + + + + + + + + + + + + diff --git a/jquery_exercise/main.js b/jquery_exercise/main.js new file mode 100644 index 00000000..b2d76b37 --- /dev/null +++ b/jquery_exercise/main.js @@ -0,0 +1,25 @@ +$(function() { + + $("form").on("submit", function(e) { + e.preventDefault(); + + var $newTitle = $('#newTitle').val() + var $newURL = $('#urlToAdd').val() + var icon = "" + var $newLi = $("
  • " + icon + " " + $newTitle + " " + $newURL + "
  • "); + $("ol").append($newLi); + + $newTitle.val(""); + $newURL.val(""); + }); + + + $('ol').click(function(event){ + $(event.target).toggleClass('glyphicon-star-empty glyphicon-star'); + }); + +}); + + + + diff --git a/jquery_exercise/style.css b/jquery_exercise/style.css new file mode 100644 index 00000000..e69de29b diff --git a/lodash_exercise/lodash.js b/lodash_exercise/lodash.js index 483d734a..c9c7aa81 100644 --- a/lodash_exercise/lodash.js +++ b/lodash_exercise/lodash.js @@ -1,85 +1,284 @@ -function drop(){ - +function drop(arr, num){ + var dropArr = []; + if(num === undefined) { + num = 1; + } + for(var i = num; i < arr.length; i++) { + dropArr.push(arr[i]) + } + return dropArr; } -function fromPairs(){ - +function fromPairs(arr){ + var pairsObj = {}; + for(var i = 0; i < arr.length; i++) { + pairsObj[arr[i][0]] = arr[i][1]; + } + return pairsObj; } function head(){ - + if(arguments[0].length === 0) { + return undefined + } else { + return arguments[0][0]; + } } -function take(){ - +function take(arr, num){ + var takeArr = []; + if(arr.length === 0) { + return takeArr; + } + if(num === undefined) { + takeArr.push(arr[0]); + } + if(num > arr.length) { + num = arr.length; + } + + for(var i = 0; i < num; i++) { + takeArr.push(arr[i]); + } + return takeArr; } -function takeRight(){ - +function takeRight(arr, num){ + var arrRt = []; + if(num === 0) { + return arrRt; + } + if(num === undefined) { + arrRt.push(arr[arr.length-1]); + } + if(num > arr.length) { + num = 1 + } + for(var i = num-1; i < arr.length; i++) { + arrRt.push(arr[i]); + } + return arrRt; } -function union(){ - +function union(arrays){ + var uniqArr = []; + var singleArr = []; + + for(var i = 0; i < arguments.length; i++) { + singleArr = singleArr.concat(arguments[i]) + } + for(var i = 0; i < singleArr.length; i++) { + if(uniqArr.indexOf(singleArr[i]) === -1) { + uniqArr.push(singleArr[i]); + } + } + return uniqArr; } -function zipObject(){ - +function zipObject(arr1, arr2){ + var zipObj = {}; + for(var i = 0; i < arr1.length; i++) { + zipObj[arr1[i]] = arr2[i]; + } + return zipObj; } -function includes(){ - +//Checks if value is in collection. If collection is a string, it's checked for a substring of value, otherwise SameValueZero is used for equality comparisons. If fromIndex is negative, it's used as the offset from the end of collection. +function includes(collection, value, indx){ +//REFACTOR + if(indx !== undefined) { + startPt = indx; + } else { + startPt = 0; + } + if(typeof collection === 'string') { + if(collection.indexOf(value, startPt) !== -1) { + return true; + } + return false + } else if(Array.isArray(collection)) { + if(collection.indexOf(value, startPt) !== -1) { + return true + } + return false + } else { + for (var n in collection) { + if(collection[n] === value) { + return true; + } + } + } } -function sample(){ - +function sample(arr){ + var randomIndex = Math.floor(Math.random() * arr.length); + return arr[randomIndex]; } -function cloneDeep(){ - +function cloneDeep(collection){ + var finalArr = []; + function cloneDeepHelper(coll) { + for(var i = 0; i < coll.length; i++) { + if(Array.isArray(coll[i])) { + finalArr.push(coll[i]); + } else { + var obj = {}; + for(var n in coll[i]) { + obj[coll[i][n]] = coll[i][n]; + finalArr.push(obj[coll[i][n]]); + } + } + } + } + cloneDeepHelper(collection); + return finalArr; } -function sumBy(){ - +function sumBy(arr, param){ + var total = 0; + for(var i = 0; i < arr.length; i++) { + if(typeof param === 'function') { + total += param(arr[i]); + } else { + total += arr[i][param]; + } + } + return total; } -function inRange(){ +function inRange(num, start, end){ + + if (end === undefined) { + end = start; + start = 0; + } + if (start > end) { + var holder = start; + start = end; + end = holder; + } + if(num >= start && num < end) { + return true; + } return false; } -function has(){ - +function has(obj, path){ + if(Array.isArray(path)){ + var arrPath = path.join("."); + if( obj+ arrPath === undefined) + return false; + return true; + } + + if(obj.hasOwnProperty(path)) + return true; + return false; } -function omit(){ - +function omit(obj, paths){ + //create a copy of obj + var copy = Object.assign({}, obj); + for(var i = 0; i < paths.length; i++) { + delete copy[paths[i]]; + } + return copy; } -function pick(){ - +function pick(obj, paths){ + var finalObj = {}; + + for(let val of paths) { + finalObj[val] = obj[val]; + } + return finalObj; } -function pickBy(){ - +function pickBy(obj, predicate){ + var finalObj = {}; + for(var n in obj) { + if(predicate(obj[n])) { + finalObj[n] = obj[n]; + } + } + return finalObj; } -function omitBy(){ - +function omitBy(obj, predicate){ + var finalObj = {}; + for(var n in obj) { + if(!predicate(obj[n])) { + finalObj[n] = obj[n]; + } + } + return finalObj; } -function padEnd(){ - +function padEnd(str, len, chars){ + var sl = str.length; + if(sl === len) { + return str; + } + if(sl < len & chars === undefined) { + for(var i = 0; i < len-sl; i++) { + str +=" "; + } + return str; + } + if(sl > len) { + str = str.substring(0, len); + } + if(sl < len) { + var loops = (len-sl)/chars.length; + if(loops % 2 === 0) { + for(var i = 0; i < loops; i++) { + str += chars; + } + } else { + for(var i = 0; i < Math.ceil((len-sl)/chars.length); i++) { + str += chars; + } + str = str.substring(0, len); + } + return str; + } } -function repeat(){ - +function repeat(str, num){ + var finalStr = ""; + if(num === undefined) { + return ""; + } + for(var i = 0; i < num; i++) { + finalStr += str; + } + return finalStr; } function upperFirst(str){ - + var result = str.split(""); + result[0] = result[0].toUpperCase(); + var finalStr = result.join(""); + return finalStr; } -function flatten(){ - +function flatten(array){ + var finalArr = [] + + function flattenHelper (arr) { + for(var i = 0; i < arr.length; i++) { + if(Array.isArray(arr[i])) { + for(var j = 0; j < arr[i].length; j++) { + finalArr.push(arr[i][j]); + } + } else { + finalArr.push(arr[i]); + } + } + return finalArr; + } + flattenHelper(array); + return finalArr; } function zip(){ diff --git a/prototypes_exercise/prototypes.js b/prototypes_exercise/prototypes.js index e69de29b..3fc13697 100644 --- a/prototypes_exercise/prototypes.js +++ b/prototypes_exercise/prototypes.js @@ -0,0 +1,48 @@ +function Person(fName, lName, favColor, favNum, favFoods ) { + this.firstName = fName, + this.lastName = lName, + this.favoriteColor = favColor, + this.favoriteNumber = favNum, + this.favoriteFoods = []; + this.family = []; +} + + +Person.prototype.fullName = function() { + return `${this.firstName} ${this.lastName}`; +}; + + +Person.prototype.toString = function() { + return `${this.fullName()}, Favorite Color: ${this.favoriteColor}, Favorite Number: ${this.favoriteNumber}`; +}; + + +Person.prototype.addToFamily = function(person) { + if(person instanceof Person && !this.family.includes(person)) { + this.family.push(person); + return this.person; + } +}; + +Array.prototype.map = function(cb) { + var newArr = []; + for(let i = 0; i < this.length; i++) { + newArr.push(cb(this[i], i, this)); + } + return newArr; +} + + +String.prototype.reverse = function() { + return this.split("").reverse().join(""); +} + +// still working on figuring out bind + + + + + + + diff --git a/recursion_exercise/recursion.js b/recursion_exercise/recursion.js index e69de29b..30dc81e8 100644 --- a/recursion_exercise/recursion.js +++ b/recursion_exercise/recursion.js @@ -0,0 +1,82 @@ +//productOfArray +function productOfArray(arr) { + if(arr.length === 0) { + return 1; + } + return arr[0] * productOfArray(arr.slice(1)); +} + +//collectStrings +function collectStrings(obj) { + + var finalArray = []; + + function collectStringsHelper(objH) { + + for(var n in objH) { + + if(typeof objH[n] === 'string') { + finalArray.push(objH[n]); + } else { + return collectStringsHelper(objH[n]) + } + } + + } + collectStringsHelper(obj); + return finalArray; + +} + +//contains +//input: nested object +//output: boolean +//process: recurse thru a nested object and look for a value +function contains(obj, val) { + for (var key in obj) { + if (obj[key] === val) { + return true; + } + + if (typeof obj[key] === 'object') { + if (contains(obj[key], val)) { + return true; + } + } + } + + return false; +} + + +function search(arr, val) { + var indx = 0; + function searchHelper(recArr, val) { + if(recArr[0] === val) { + return indx; + } else if(recArr.length > 1) { + indx++; + recArr.shift(); + searchHelper(recArr, val); + } else { + indx = -1 + return indx + } + } + searchHelper(arr, val); + return indx; +} + + + + + + + + + + + + + + diff --git a/recursion_exercise/recursionSpec.js b/recursion_exercise/recursionSpec.js index 5bc841fe..2306ee0a 100644 --- a/recursion_exercise/recursionSpec.js +++ b/recursion_exercise/recursionSpec.js @@ -78,8 +78,8 @@ describe("#search", function(){ expect(search([1,2,3,4,5,6,7],6)).to.equal(5) }); it("should return -1 if the value is not found", function(){ - expect(search([1,2,3,4]),0).to.equal(-1) - expect(search([1,2]),11).to.equal(-1) + expect(search([1,2,3,4],0)).to.equal(-1) + expect(search([1,2],11)).to.equal(-1) }); }); diff --git a/testing_exercise/testing.js b/testing_exercise/testing.js index e69de29b..02f0eaa3 100644 --- a/testing_exercise/testing.js +++ b/testing_exercise/testing.js @@ -0,0 +1,39 @@ +function replaceWith(str, charToFind, charReplacement) { + var find = charToFind; + var re = new RegExp(find, 'g'); + return str.replace(re, charReplacement) +} + + +function expand(arr, num) { + var finalArr = []; + for (var i = 0; i < num; i++) { + finalArr = finalArr.concat(arr); + } + return finalArr; +} + +function acceptNumbersOnly() { + for(var i = 0; i < arguments.length; i++) { + if(typeof arguments[i] !== 'number' || isNaN(arguments[i])) { + return false; + } + } + return true; +} + +function mergeArrays(arr1, arr2) { + var singleArr = arr1.concat(arr2); + var finalArr = singleArr.sort(); + return finalArr; +} + +function mergeObjects(obj1, obj2) { + var finalObj = obj1; + for(var n in obj2) { + finalObj[n] = obj2[n]; + } + return finalObj +} + + diff --git a/testing_exercise/testingSpec.js b/testing_exercise/testingSpec.js index aef56b1d..a3260953 100644 --- a/testing_exercise/testingSpec.js +++ b/testing_exercise/testingSpec.js @@ -1,3 +1,49 @@ + + +// WRITE YOUR TESTS HERE! + +//replaceWith test var expect = chai.expect; -// WRITE YOUR TESTS HERE! \ No newline at end of file +describe("case sensitve letter replacement", function() { + it("replaces charToFind with charReplacement", function() { + expect(replaceWith('Foo', 'F', 'B')).to.equal('Boo'); + expect(replaceWith("awesome", "e", "z")).to.equal("awzsomz") + }) +}) + +//expand test +describe("concatenation of arrays", function() { + it("returns an array that has been copied", 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"]); + }) +}) + +//acceptNumbersOnly test +describe("confirm if all arguments are numbers", function() { + it("returns a boolean indicating if all args are numbers", function() { + expect(acceptNumbersOnly(1,2,3,4,5,6,7)).to.equal(true); + expect(acceptNumbersOnly(1,2,3,4,5,6,NaN)).to.equal(false); + }) +}) + +//mergeArrays test +describe("takes in two arrays", function() { + it("returns a sorted array", function() { + expect(mergeArrays([2,1],[3,4])).to.deep.equal([1,2,3,4]); + }) +}) + +//mergeObjects test +describe("takes in two objects", function() { + it("returns one object with all properties", function() { + expect(mergeObjects({name: "Foo", num: 33}, {test: "thing", num: 55})).to.deep.equal({name: "Foo", test: "thing", num: 55}) + }) +}) + + + + + +