0

How to remove a part of a string in js?

For example: let text = "Hello World!;" console.log("Before: " + text); text.remove( 5, 7); console.log("After: " + text); Expected output: Before: Hello World! After: Hello

23rd Feb 2023, 9:47 AM
Yeeter
Yeeter - avatar
1 Réponse
+ 3
Use substr function console.log(text.substr(0, 5)); // Hello
23rd Feb 2023, 10:00 AM
A͢J
A͢J - avatar