Arrays

Slice Range Copy

Slice Range Copy

slice copies part of an array into a new array. The start index is included, and the end index is where the copy stops before that position.

Use this when code needs a visible section of a longer list but the original list should remain available unchanged.

Your task: Use slice to create visibleLessons from the middle three lessons in lessonQueue. Keep lessonQueue unchanged, then log the copied range.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Slice Range Copy

slice copies part of an array into a new array. The start index is included, and the end index is where the copy stops before that position.

Use this when code needs a visible section of a longer list but the original list should remain available unchanged.

Your task: Use slice to create visibleLessons from the middle three lessons in lessonQueue. Keep lessonQueue unchanged, then log the copied range.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.