Truncate String at Whitespace

# Introduction In this lab, we will explore the concept of truncating a string at whitespace in JavaScript. We will learn how to limit the length of a string while preserving its readability by respecting whitespace. Through the implementation of `String.prototype.slice()` and `String.prototype.lastIndexOf()`, we will create a function that can truncate a string to a specified length with an optional ending.

|
60 : 00

Click the virtual machine below to start practicing