Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #5729

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #5729

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var chocolateBars = [
'snickers', 'hundred grand','kitkat', 'skittles'];
function addElementToBeginningOfArray (array,element){ //done
var new_array = [element,...array]
return new_array
}
function destructivelyAddElementToBeginningOfArray(array , element){//done
array.unshift(element)
return array
function destructivelyAddElementToEndOfArray(array, element) {
array.push(element)
return array
}
function addElementToEndOfArray(array, element){
return [...array,element]
}
}
function accessElementInArray(array, index){ // done
return array[index]
}
function destructivelyRemoveElementFromBeginningOfArray(array){ //done
array.shift()
return array
}
function removeElementFromBeginningOfArray(array){ // done
var removed = array.slice(1)
return removed
}
function destructivelyRemoveElementFromEndOfArray(array){ //done
array.pop()
return array
}
function removeElementFromEndOfArray(array){//done
var new_array = array.slice(0,-1)
return new_array
}