This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = {}; | |
/*********IDENTITY**********/ | |
_.identity = function(val) { | |
return val; | |
}; | |
/*********FIRST**********/ | |
_.first = function(array, n) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #2 | |
/* | |
Write an "assertArraysEqual" function from scratch. | |
Assume that the arrays in question contain only scalar values (i.e., simple values like strings or numbers). | |
Do not use JSON.stringify(), Array.join(), or any other "convert the array to a string so I can compare two strings" type of technique to implement this. | |
Examples | |
SUCCESS CASE | |
var expected = ['b', 'r', 'o', 'k', 'e', 'n']; | |
var actual = 'broken'.split(''); | |
assertArraysEqual(actual, expected, 'splits string into array of characters'); |