我正在尝试编写一些代码来检查先前定义的变量是否有空格,如果有,则用短划线替换空格.这将嵌套在另一个函数中.
function foo(){
// If stateName has a space replaces the space with a dash
window.open('http://website.html/state-solar-policy/' + stateName);
}
Run Code Online (Sandbox Code Playgroud)