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

bookChallenge: 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.

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

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 4

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Awesome!

Completion rate improved to 2.94

bookChallenge: Modifying Arrays

Swipe to show menu

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.

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

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 4
some-alt