JSFiddle - React, Tailwind, and code Playground

JavaScript

// Do not modify this code:
Array = Array.prototype.constructor = function() {
    alert('I\'m Hijacked!  Oh no');
};
Object = Object.prototype.constructor = function(){
    alert('I\'m Hijacked!  Oh no');
};
//Sorry, D.B. says you can't modify any code above this point.

/**
 * Add this as a function on the built-in Array object!
 */
var coolCustomFunction = function() {
    alert('I have ' + this.length + ' elements!  Cool!');
};

/* The following no longer work:
* Array.prototype.coolCustomFunction = coolCustomFunction;
* [].constructor.prototype.coolCustomFunction = coolCustomFunction;
* Object.getPrototypeOf([]).coolCustomFunction = coolCustomFunction;
* ({}).constructor.getPrototypeOf([]).coolCustomFunction = coolCustomFunction;
*/


// YOUR CODE to add coolCustomFunction to the original Array prototype HERE:



//Your very own D.B.-approved unit test:
(function testCoolCustomFunction() {
    try {
        var myArray2 = [];
        myArray2.coolCustomFunction();
    } catch (e) {
        alert('Fail!');
    }
})();