Strings

Debug a Slice

Debug a Slice

slice(start, end) includes the start index but stops before the end index. Off-by-one mistakes are common when reading from the front of a string.

Your task: The function should return the first two characters of a code, but it currently returns only the second character. Fix the function.

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.

Debug a Slice

slice(start, end) includes the start index but stops before the end index. Off-by-one mistakes are common when reading from the front of a string.

Your task: The function should return the first two characters of a code, but it currently returns only the second character. Fix the function.

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.