Skip to content

Instantly share code, notes, and snippets.

@alexglazkov9
Last active April 12, 2018 18:17
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 alexglazkov9/8a66907939cedf0e5365fe736210a919 to your computer and use it in GitHub Desktop.
Save alexglazkov9/8a66907939cedf0e5365fe736210a919 to your computer and use it in GitHub Desktop.
// Copyright (C) 2015 Aleksey Glazkov. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Array.prototype.reverse() rearranges elements array so as to reverse their order.
description: Checking returned results.
---*/
var arr = [];
var original = arr;
var reversed = arr.reverse();
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
assert.sameValue(original, reversed, "Values are not the same!");
//
//////////////////////////////////////////////////////////////////////////////
arr.push(1);
original = arr;
reversed = arr.reverse();
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
assert.sameValue(original, reversed, "Values are not the same!");
//
//////////////////////////////////////////////////////////////////////////////
arr.push(1);
original = arr;
reversed = arr.reverse();
//////////////////////////////////////////////////////////////////////////////
//CHECK#3
assert.sameValue(original, reversed, "Values are not the same!");
//
//////////////////////////////////////////////////////////////////////////////
arr = new Array(1,2,3);
reversed = arr.reverse();
//////////////////////////////////////////////////////////////////////////////
//CHECK#4
assert(compareArray(reversed, [3,2,1]), "Arrays do not match!");
//
//////////////////////////////////////////////////////////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment