Took 12 minutes 48 seconds to implement JavaScript array length property. The maximum length of the array can only be 10000. Here is the code snippet.
Function:
arr = ['1', '2', '3', '4'];
count = 0;
function length(arr) {
for (var i = 0; i < 10000; i++) {
if(arr[i] != undefined) {
count++;
}
}
return count;
}
document.write(length(arr));
Result:
4
No comments:
Post a Comment