// compareArrays(array a, array b)
//
// compares two arrays
// returns true if similar, false if dissimilar
const compareArrays = (a, b) => {
	// if array a and b have a different number of elements
	if(a.length != b.length){
		// They are dissimilar
		return false;
	}
	// Loop through each element of array a and b
	for(var i = 0; i < a.length; i++){
		// if elements i of arrays a and b are dissimilar
		if(a[i] != b[i]){
			// The arrays are dissimilar
			return false;
		}
	}

	// Finally after all checks have passed, arrays are similar
	return true;
}

module.exports = compareArrays;

// compareArrays needs to be a function
console.assert(typeof compareArrays === 'function', 'compareArrays should be a function');
// compareArrays should take in two arguments
console.assert(compareArrays.length === 2, 'compareArrays should take in two values');
// compareArrays should return a boolean value
console.assert(typeof compareArrays([],[]) === 'boolean', 'compareArrays should return a boolean value');
// compareArrays should successfully compare two similar arrays
console.assert(compareArrays(['a','b','c'],['a','b','c']), 'compareArrays should return true for arrays [a,b,c] and [a,b,c]');
// compareArrays should successfully compare two dissimilar arrays of the same length
console.assert(!compareArrays(['a','b','c'], ['a','a','a']), 'compareArrays should return false for arrays [a,b,c] and [a,a,a]');
// compareArrays should successfully compare two empty arrays
console.assert(compareArrays([],[]), 'compareArrays should return true for two empty arrays');
