To do that, we’ll need to add two parameters inside the
- The starting point (0)
- The number of items to remove (1)
Here’s an example where we correct a misspelled company name:
const companyName = "Netflixx" const fixCompanyName = companyName.slice(0, -1) console.log(fixCompanyName) // output: 'Netflix'
splice() method does not modify the original variable value
Netflixx, that one still exists. We created a new variable (
fixCompanyName) that we assign the correct spelling to — and then reference that variable whenever we need to access the company name in a project.