function vehicle(strings, type) {
var wheels= "no";
if(type === "car"){ wheels = 4;}
else if(type === "cycle"){ wheels = 2;}
return `${strings[0]}${wheels}${strings[1]}`;
}
var type = "car";
var output = vehicle`This vehicle has ${type} wheels.`;
console.log(output); //This vehicle has 4 wheels.
在数据库中保存"vehicle`This vehicle has ${type} wheels.`"
的最佳方法是什么?我可以进行一些字符串操作,但想知道更好的方法。