forked from Automedon/CodeWars-7-kyu-Soluitions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray.prototype.size().js
More file actions
21 lines (17 loc) · 853 Bytes
/
Copy pathArray.prototype.size().js
File metadata and controls
21 lines (17 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
Description:
Implement Array.prototype.size() - without .length !
Implement Array.prototype.size(), which should simply return the length of the array. But do it entirely without using Array.prototype.length!
Where .length is a property, .size() is a method.
Rules
Because it is quite impossible to disable [].length, and because filtering for "length" is an iffy proposition at best,
THIS KATA WORKS ON THE HONOUR SYSTEM.
You may cheat. But you may have trouble sleeping. Or $DEITY may kill a puppy.
You need not support sparse arrays (but you may!). All testing will be done with dense arrays.
Values will not be undefined. You need only support actual, real arrays.
Your method needs to be read only. Arguments must be ignored. The this object must not be modified.
Be creative!
*/
Array.prototype.size = function() {
return this.length;
};