Ask coding questions

← Back to all posts
PLEASE HELP
faziz6006 (2)

Exercise Two: you will be given an array called 'snacks'
// Using an array method, add your favorite snack to the end of the array

Commentshotnewtop
DeShawnKeller (0)

Did you ever get the answer to this?? I cannot figure this one out for nothing!! What I got so far--------

function exerciseTwo(snacks){
// Exercise Two: you will be given an array called 'snacks'
// Using an array method, add your favorite snack to the end of the array
function exerciseTwo(snacks){
var snacksArray = ["chips", "popcorn", "ice cream"];
snacksArray.push('oreo');

}

vedprad1 (732)
function exerciseTwo(snacks) {
  snacks.push('French Fries');
}

Do similar things with the other exercises.

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!

vedprad1 (732)

If you are using JavaScript, you can use the push() method.


If you are using Java, you can make a new array with a larger size, copy the elements from the original array, and put your snack as the last element.

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!

faziz6006 (2)

@vedprad1 is there any way you could help me more? im doing the precourse work and i need help lol im stuck on these four questions