
Lunch Picker
//Building a Lunch Picker Program /*n this lab, you'll build a program that helps in managing lunch options. You'll work with an array of lunches, add and remove items from the array, and randomly select a lunch option. */ //create an empty array let lunches = []; //create a function //give it two arguments which one is an array and the second is a string //this function should add the string argument to the end of the array and log it to the console //return the updated array function addLunchToEnd(arr, lunchItem) { arr.push(lunchItem); console.log( ${lunchItem} added to the end of the lunch menu. ); return arr; } //create a secondn function //give it two arguments: an array as first and a string as a second //this function should add the string argument to the beginning of the array and log it to the console //return the updated array function addLunchToStart(arr, lunchItem) { arr.unshift(lunchItem); console.log( ${lunchItem} added to the beginning of the lunch menu. ); return arr; }
Continue reading on Dev.to
Opens in a new tab




