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

291
Vistas
Hay seis funciones, lea cada comentario y escriba las declaraciones de retorno para cada uno de ellos

Hola a todos, espero poder obtener ayuda aquí y alguien puede explicarme esto. Estoy en una clase de codificación y no puedo resolver esto por mi vida. Este es el código que necesito para terminar. Parece que no puedo hacer esto bien. ¿Alguien puede ayudar? Intenté agregar las líneas de código necesarias de varias maneras diferentes, así que finalmente reinicié todo y estoy perdido.

 // 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

No dices qué idioma es este, pero supongo que es javascript. La pregunta le pide que encuentre la sintaxis para leer o manipular la matriz inicial y etiquetarla al final de una declaración de devolución. Entonces, la primera respuesta podría ser algo como: return arr[0] , que debería mostrar el primer elemento (sin índice) en la matriz. Toda la función entonces se ve así:

 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