Skip to content

Instantly share code, notes, and snippets.

@PatMB30
Created March 15, 2018 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatMB30/7a483999a2986b8358c4155d74c587e8 to your computer and use it in GitHub Desktop.
Save PatMB30/7a483999a2986b8358c4155d74c587e8 to your computer and use it in GitHub Desktop.
testing the comparison and reversing if middle element is non-numerical
// Copyright (C) 2015 Patrick G. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: arrayComparison reorders the elements of the array in reverse using Array.reverse
description: testing the comparison and reversing if middle element is non-numerical
---*/
var arr1 = [2,4,"string",6,8];
var arr1Copy = arr1.reverse();
var arr2 = [1,3,"string2",5,7];
//////////////////////////////////////////////////////////////////////////////////
//CHECK 1
assert.sameValue(arr1Copy[0], 8, "arr1Copy[0] === 8");
assert.sameValue(arr1Copy[1], 6, "arr1Copy[1] === 6");
assert.sameValue(arr1Copy[3], 4, "arr1Copy[3] === 4");
assert.sameValue(arr1Copy[4], 2, "arr1Copy[4] === 2");
//////////////////////////////////////////////////////////////////////////////////
//CHECK 2
assert.sameValue(arr1Copy, arr1, "returns the same object");
//////////////////////////////////////////////////////////////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment