Took 13 minutes and 24 seconds to implement JavaScript shift() function. Here is the code snippet.
Function:
arr=['a', 'b', 'c'];
function shift(arr) {
for (var i = 0; i < arr.length; i++) {
arr[i] = arr[i+1];
}
arr.pop();
return arr;
}
shift(arr);
document.write(arr);
Result:
b,c
No comments:
Post a Comment