我正在尋找包裝字串的方法,例如我想將字串轉換"student"為 "$student$". 我怎樣才能在 javascript 中實作它?
uj5u.com熱心網友回復:
您可以像這樣使用模板文字:
const wrapIntoDollars = (string) => {
return `$${string}$`;
}
console.log(wrapIntoDollars("student"));
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/535264.html
標籤:javascript细绳
