Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
There are six functions, read each comment and write the return statements for each of them

Hi everyone I am hoping I can get some help here and someone can explain this to me. I am in a coding class and I cannot figure this out for the life of me. This is the code I need to finish. I cannot seem to get this right. Can anyone help? I have tried to add the lines of code needed multiple different ways so I finally restarted everything and I am lost.

// Instructions
// - Given the following 6 empty functions, add the right return statement to each of 
them to complete the activity
// Please do not change any of the function names

//This is your starting array
const arr = [10, 10, 16, 12];

function returnFirst(arr) {
  // return the first item from the array
}

function returnLast(arr) {
  // return the last item of the array
}

function getArrayLength(arr) {
  // return the length of the array
}

function incrementByOne(arr) {
  // arr is an array of integers(numbers), Increment all items in the array by
  // return the array
}

function addItemToArray(arr, item) {
  // add the parameter item to the end of the array arr
  // return the array
}

function addItemToFront(arr, item) {
  // add the parameter item to the front of the array arr
  // return the array
  // hint: use the array method .unshift
}

//uncomment these lines to check results in browser console
// console.log("returnFirst result:" + returnFirst(arr))
// console.log("returnLast result:" + returnLast(arr))
// console.log("getArrayLength result:" + getArrayLength(arr))
// console.log("incrementByOne result:" + incrementByOne(arr))
// console.log("addItemToArray result:" + addItemToArray(arr, 10))
// console.log("addItemToFront result:" + addItemToFront(arr, 10))

//////////////////////////////////
//don't change this line
if (typeof module !== 'undefined') {
  module.exports = {
    returnFirst,
    returnLast,
    getArrayLength,
    incrementByOne,
    addItemToArray,
    addItemToFront,
  };
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You don't say what language this is but I assume it's javascript. The question is asking you to find the syntax to read or manipulate the initial array and tag it onto the end of a return statement. So the first answer might be something like: return arr[0] which should show the first (zero indexed) item in the array. The whole function then looks like:

function returnFirst(arr) {
  // return the first item from the array
  return arr[0];
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda