xxxxxxxxxx
// Using length and slice() to trim a string from the end
let fileName = "Document.pdf";
console.log(fileName.slice(0, fileName.length - 4));
// Output: "Document"
// Using length and slice() to trim a string from the end
let sentence = "This is a sentence.";
console.log(sentence.slice(0, sentence.length - 1));
// Output: "This is a sentence"
// Using length and slice() to trim a string from the end
let userInput = "Hello ";
console.log(userInput.slice(0, userInput.length - 1));
// Output: "Hello"