Nodejs Array Multiply mutilate(start, end)

Here you can find the source of mutilate(start, end)

Method Source Code

var arr = ["Devin Hardy", "Seth Rollins", "Cole Sprouse"];


Array.prototype.mutilate = function(start, end) {
   var newArr = [];

   if (end > this.length || start > this.length) {
      throw new Error("Invalid opperation.");
   } else {/*from  ww  w.  j  a  va 2s  .c  o  m*/

      arr2 = this.slice(start, end);
      newArr.push(arr2);
   }

   return newArr;

};

Related

  1. multiply(n)
    Array.prototype.multiply = function(n){
      results = []
      for (var i = 0; i < this.length; i++){
        for (var j = 0; j < n; j++){
          results.push(this[i])
      return results
    
  2. multiplyByTwo()
    Array.prototype.multiplyByTwo = function() {
      var newArr = [];
      for (var i = 0; i < this.length; i++) {
        newArr.push(this[i] * 2)
      return newArr;
    };
    console.log([1, 2, 3].multiplyByTwo());
    Array.prototype.myEach = function(func) {
    ...
    
  3. multislice(ranges)
    Array.prototype.multislice = function(ranges) {
      if(typeof ranges === 'undefined')
        throw Exception("Ranges have to be defined!");
      if(typeof ranges !== 'object') 
        throw Exception("You have to pass an array!");
      return ranges.map(el => this.slice(el.from, el.to));
    };
    
  4. multislice(ranges)
    'use strict';
    var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { 
      return typeof obj; 
      } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
    Array.prototype.multislice = function (ranges) {
      var _this = this;
      if (typeof ranges === 'undefined') throw Exception("Ranges have to be defined!");
      if ((typeof ranges === 'undefined' ? 'undefined' : _typeof(ranges)) !== 'object') throw Exception("You have to pass an array!");
      return ranges.map(function (el) {
    ...
    
  5. multisplice()
    Array.prototype.multisplice = function(){
      var args = arguments[0], 
        res = [];
      args.sort( function(a, b){
         return a - b;
       });
      for(var i = 0; i < args.length; i++){
        var index = args[i] - i;
        res.push( this.splice(index, 1)[0] );
    ...