Exercise: String Slicing
Explore how to apply the slice method on strings and arrays, and understand the use of sorting with localCompare in JavaScript. This lesson helps you practice sorting string rows while preserving headers, improving your skills in string manipulation and array handling techniques.
We'll cover the following...
We'll cover the following...
Sort the rows given below based on their titles. Make sure you exclude the header row.
Hint: the
slicemethod works in the same way on arrays as on strings.
Solution
First, we get rid of the first row:
We have to sort the data rows using the array sort ...