Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Modifying Arrays | Arrays
Introduction to TypeScript

book
Challenge: Modifying Arrays

Task

You are given two arrays. Your task is to remove the first and last elements from each of the arrays and then display the combined array on the screen. Use the methods we learned in this section. If you have difficulty understanding the task, you can use the Hint and Solution buttons to view and analyze the solution.
This way, you'll grasp the information better.

let firstArray: (number | string)[] = [0, 1, 2, 3, 4, 5];
let secondArray: (number | string)[] = ['zero', 'one', 'two', 'three', 'four', 'five']
firstArray.___(); //removing the last element
secondArray.___(); //removing the last element
firstArray.___(); //removing the first element
secondArray.___(); //removing the first element
let mixedArray: (___ | ___)[] = firstArray.___(___); //mixing two arrays into one
console.log(mixedArray); // printing mixed array
12345678
let firstArray: (number | string)[] = [0, 1, 2, 3, 4, 5]; let secondArray: (number | string)[] = ['zero', 'one', 'two', 'three', 'four', 'five'] firstArray.___(); //removing the last element secondArray.___(); //removing the last element firstArray.___(); //removing the first element secondArray.___(); //removing the first element let mixedArray: (___ | ___)[] = firstArray.___(___); //mixing two arrays into one console.log(mixedArray); // printing mixed array
copy

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 4

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt