Usuń pierwszy i ostatni znak z String JavaScript
const removeChar = (str) => str.slice(1, -1);
Fylls
const removeChar = (str) => str.slice(1, -1);
String roles = "[This is an example of list.toString()]";
//Below substring method will remove the first and last character of roles String
roles = roles.substring(1, roles.length()-1);
// here roles will become "This is an example of list.toString()"
System.out.println("New String: "+roles);
// Remove first and last letter of string
fn main() {
let text = "Hello, world";
// remove last letter
let mut text = text.split_at(text.len() - 1);
// remove first letter
text = text.0.split_at(1);
println!("{}", text.1);
}
// Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You don't have to worry with strings with less than two characters.
function removeChar(str){
const strLength = str.length
if(strLength < 2) return str
return str.substr(1, strLength - 2)
};
// With love @kouqhar