I want to convert a string such as 'String' to the stripped version of that (I think thats the word?), something like this:
const strip = r => {
/* Code */
}
What I want is:
> strip('String')
> String
basically I just want it to remove the quotes from around a string (I want the output to be a none-type)
CodePudding user response:
Is this what you are after?
var test = "\"'String \" with 'quotes'\"";
test = test.replace(/['"]/g, "");
console.log("test: " test);
CodePudding user response:
In your example, the string passed as an argument to the strip
function does not have quotes in its content. You're just telling that function that the r
parameter is of type string with the content String
.
To answer to your question, you can remove the quotes of a string by removing the first and last character:
const strip = str => {
return str.slice(1, -1);
}
strip('"String"') => String